dev@javaserverfaces.java.net

Re: h:inputTextArea swallows one leading newline

From: Daniel Lichtenberger <daniel.lichtenberger_at_gmx.net>
Date: Thu, 18 Apr 2013 11:36:52 +0200

Hi Ed,

On 04/11/2013 05:30 PM, Edward Burns wrote:
> I hope things are going well at fliXive. I was hoping to see you at
> CONFESS Vienna last week. Did you go?

I didn't make it this time, but things are going well ;-)

> DL> So basically you'd need to emit a newline before rendering the value
> DL> of the textarea, since it will always be ignored. This hack works
> DL> for me (it's for the Primefaces textarea renderer, but Mojarra's
> DL> renderer has the same writeText call):
>
> DL> if(valueToRender != null) {
> DL> writer.writeText("\n", "value");
> DL> writer.writeText(valueToRender, "value");
> DL> }
>
> DL> What's the appropriate way of doing this?
>
> How about this. We could add some additional text the javax.faces.Text
> javax.faces.Input renderer to say, if the value to be rendered starts
> with whitespace, determine the appropriate number of spaces by counting
> the number of preceding \n chars and issue that many
> writer.writeText("\n", "value") calls. Then render the value with the
> leading whitespace removed.
>
> I'd have to get permission from the EG for this kind of change, though.

I guess this would work, but the result would be the same as always
writing a "\n" before the value (as it is/should always be ignored),
without having to parse the value that should be rendered.

Daniel


-- 
DI Daniel Lichtenberger
UCS - unique computing solutions gmbh
Salztorgasse 1/2A
A-1010 Wien
t: +43 1 7182121 70
f: +43 1 7182121 90
e: daniel.lichtenberger_at_ucs.at
w: http://www.ucs.at