wood burning stoves 2.0*
The moose likes JSF and the fly likes Prevent data in h:inputTextArea from being submitted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Prevent data in h:inputTextArea from being submitted" Watch "Prevent data in h:inputTextArea from being submitted" New topic
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
Bartender

Joined: Aug 06, 2010
Posts: 516
    
    4

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 SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
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
Bartender

Joined: Aug 06, 2010
Posts: 516
    
    4

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: 15961
    
  19

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: 15961
    
  19

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
Bartender

Joined: Aug 06, 2010
Posts: 516
    
    4

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prevent data in h:inputTextArea from being submitted
 
Similar Threads
Can't display large amounts of text - help
Form submission in struts 1.2
Problem in submitting parameters characters which contains +,%
Crazy post and get methods, help....
avoid form submission