help with <h:inputTextarea>

Hello,

I tried to use <h:inputTextarea> display text from database, the line items were stored in database and separated by Carriage Return like this:

line 1 +CRLF ("\r\n") + line 2 + CRLF ("\r\n") .....

and the text out put need like this:

__

line 1

line 2

line 3

...

- JSF code --

<h:inputTextarea styleClass="inputTextarea" id="textarea1"

cols="50" rows="10" value="#{MyBean.lines}" readonly="true" style="overflow:hidden">

</h:inputTextarea>

MyBean.java

public String getLines(){

// get lines String

return lines;

}

==============

But I have the error pop up box as follows due to the Carriage Return CRLF ("\r\n") I think:

Line:963

Char: 768

Error: Unterminated string constant

code:0

URL....

--

how to solve the problem or maybe I did not use <h:inputTextarea>correctly? If so, how to use it to display multi lines?

Thanks for your help!

[1366 byte] By [zcona] at [2007-11-27 7:06:16]
# 1

Hi

It seems that ur problem is due to CRLF("\r\n")function

if ur function return string like this ( return string from method binded in <h:inputTextArea> value Attribute)

line 1 +"\r\n" + line 2 + "\r\n".....

it will definetly work properly.

and the output will be according to ur requirement

PRohillaa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
well why not make use of System.getProperty("line.seperator") instead of CRLF("\r\n")NOTE:System.getProperty("line.seperator") is more native.. just rethink while applying it.
RahulSharnaa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

if this CRLF is already used and stored in database then 'CRLF(' and ')' sholuld be removed from line instead of getting System.lineSeparator , beacause this is already stored in database.

Yout option can be used if database can be repopulated.

here System.lineSeparator can be used instead of CRLF function

PRohillaa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

I don't think the problem should be with the choice of line separator. First, the issue occurs on the client, not the server. So using the line separator property from System will give you the separator on the server, not the client.

Second, the problem is coming from JavaScript; I don't believe that the inputTextArea component renders the value within a JavaScript constant.

So what I would do here is view the source in the browser and look at what is happening on line 963. If you can, post the code here.

RaymondDeCampoa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

I had tried System.getProperty("line.seperator"), got same error, I looked on line 963 it is because the CRLF there since if I remove it it is OK no error, BUT if I remove the CRLF after from database, how can I out put the lines like within the <h:inputTextarea>, Does anyone know a solution? Thanks for your help...!

--

line 1

line 2

line 3

-

zcona at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Please post the generated code that causes the error. I am willing to bet it has nothing to do with the inputTextarea tag.
RaymondDeCampoa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

Why not substitute a

for CRLF. BTW I would avoid using markup in value of text area. Note: JSF documentation

Creates a user input text area for multiple lines of text. Displays an HTML <textarea> element with a name attribute set to the component's client ID and a body holding the component's value.

smurray_eriea at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Thanks all for your kind reply !

not working, I have the output in <h:inputTextarea> in one line like this :

line1 <br> line2

......

Can <h:inputTextarea> automatically separate the text line by line if any special markup there such as CRLF .... if not, what can I use ? I was think using dataTable to display a list of seperated strings , but seems not workable...

Thanks in advance !

zcona at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

> Thanks all for your kind reply !

>

>

not working, I have the output in

> <h:inputTextarea> in one line like this :

>

> line1

line2

......

>

> Can <h:inputTextarea> automatically separate the text

> line by line if any special markup there such as CRLF

> .... if not, what can I use ? I was think using

> dataTable to display a list of seperated strings ,

> but seems not workable...

>

>

> Thanks in advance !

You are seriously barking up the wrong tree. Post the generated code.

RaymondDeCampoa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
Try CSS..textAreaStyle {white-space: pre;}
BalusCa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

I think your use of inputTexaArea to display multiple lines is correct although I haven't tried to use inputTextArea with styeClass and style attributes.

The problem might be something to do with the original string, "lines", as it gave this error.

Error: Unterminated string constant

You might need to check the set property function of the 'lines' property to make sure there is end of line character for each line.

EngrThihaa at 2007-7-12 18:57:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...