| Author |
Prevent data in h:inputTextArea from being submitted
|
B Nirvan
Ranch Hand
Joined: Oct 20, 2010
Posts: 82
|
|
I am using h:inputTextArea which is populated in the backing bean. The textArea is only for displaying data so I made it readOnly. The problem is that when the form is posted back, the textArea data also gets posted to the server (which I am trying to somehow avoid). The reason for avoiding posting of textArea data is that it is too large to be posted and given the default post size , "java.lang.IllegalStateException: Post too large" is thrown when the form is submitted.
How do I avoid posting of textArea data when the form is submitted?
regards,
Nirvan.
|
 |
Dieter Quickfend
Ranch Hand
Joined: Aug 06, 2010
Posts: 280
|
|
|
If it's outside the form you're submitting, it won't be posted. disabled="true" will also exclude it from submit.
|
Oracle Certified Professional Java Programmer
|
 |
B Nirvan
Ranch Hand
Joined: Oct 20, 2010
Posts: 82
|
|
Dieter,
The textArea is inside the form, as I am populating it from backing bean. Making it disabled results in the content being greyed out and hence very difficult to read.
thanks and regards,
Nirvan.
|
 |
Dieter Quickfend
Ranch Hand
Joined: Aug 06, 2010
Posts: 280
|
|
Hello B,
the textarea doesn't need to be inside the form to populate it from the backing bean.
EDIT: little example of two ways to do it: without the JSF component and with the JSF component
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
textArea is an input control, so it's not surprising that it's input even when readonly.
Use an outputText control instead and use CSS to set its width/height to a size that suits you. And draws a textArea-style frame around the text if you want that too.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
B Nirvan
Ranch Hand
Joined: Oct 20, 2010
Posts: 82
|
|
Dieter Quickfend wrote:
Dieter,
I never thought of using textArea that way. Thanks for that trick. I have implemented it.
regards,
Nirvan.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14456
|
|
I started to mention that one as well, but didn't think it offered anything that a pure JSF solution couldn't. I'd forgotten that TextArea scrolls, though. You can do that with a <div> as well, and by extension, a JSF panel control, but it's more work, perhaps.
For best results, however, wrap any raw HTML with the f:verbatim tag.
|
 |
Dieter Quickfend
Ranch Hand
Joined: Aug 06, 2010
Posts: 280
|
|
You're very welcome! Just wanted to add one more thing:
You should know that EL-script is unsafe to use in the way I showed it, if it is unprocessed input from the user. It's no problem if you are using your own text, but if you use that textarea to output user-submitted text, know that it exposes your users to cross-site scripting.
Regards,
Dieter
|
 |
B Nirvan
Ranch Hand
Joined: Oct 20, 2010
Posts: 82
|
|
Dieter,
I am using the textArea to display some messages to the user. These messages come from a text file on the server . These messages have nothing to do with the user input. So I believe, that it wouldn't cause problems related to cross-site scripting (although I don't know much about that term).
regards,
Nirvan
|
 |
 |
|
|
subject: Prevent data in h:inputTextArea from being submitted
|
|
|