Skip to main content

h:outputLabel adding unwanted newline character to label content

2 replies [Last post]
tacitust
Offline
Joined: 2010-02-24

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 element?

That results in this:

becoming this:


Remember Me

instead of this:

Remember Me

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.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tacitust
Offline
Joined: 2010-02-24

Thanks Ryan, will do.

Ryan Lubke

Hello,

The renderkit specification doesn't require it. Haven't dug through the
history to see if there's a reason yet, but I'd recommend logging an
issue [1].

[1] https://javaserverfaces.dev.java.net

On 2/24/10 12:24 PM, webtier@javadesktop.org wrote:
> 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 element?
>
> That results in this:
>
> [b][/b]
>
> becoming this:
>
> [b][/b]
>
> instead of this:
>
> [b][/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@yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=388506
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net