webtier@glassfish.java.net

h:outputLabel adding unwanted newline character to label content

From: <webtier_at_javadesktop.org>
Date: Wed, 24 Feb 2010 12:24:43 PST

I've just come back to JSF after a multi-year absence so I'm still feeling my way a bit, but there is one thing that's current niggling me.

Is there a good reason why Mojarra 2.0.2 adds a new line character in front of the content of every <h:outputLabel> element?

That results in this:

         [b]<h:outputLabel for="rememberMe" value="Remember Me"/>[/b]

becoming this:

         [b]<label for="rememberMe">
Remember Me</label>[/b]

instead of this:

         [b]<label for="rememberMe">Remember Me</label>[/b]

While Firefox ignores the \n character in most cases, if you put a label after, say, a checkbox field, the \n is converted into a space character, and there is no way to get rid of it. It's hard coded into the Renderkit source (LabelRenderer.java line 118):

        writer.writeText("\n", component, null);

Is this a bug or a feature of the JSF spec? It seems to me that the only reason why you would add a newline was to make a source code more readable, in which case it should be added before the open label tag, not after it.
[Message sent by forum member 'tacitust' (tacitus_at_yahoo.com)]

http://forums.java.net/jive/thread.jspa?messageID=388506