JTraining Blog

Share your knowledge.
svanhugten
svanhugten

When working with JSF 1.x you will eventually find out about some of its annoying features. Such as that it is all about HTTP POST and nothing but HTTP POST. So when working with forms with inputTextArea components you will notice that refreshing or navigating away and then back will leave them blank again. Some of customers I worked for had a problem understand this limitation, because dropdown boxes just worked fine and demanded that the text areas work the same.

I found a small piece of code that will remedy this shortcoming.   

 

<a4j:support event="onchange" immediate="true">

<a4j:actionparam assignTo="#{pageBean.propertyName}"

value="this.value" noEscape="true" />

</a4j:support>

 

When putting this as child code between the h:inputTextArea tags it will demonstrate the following behavior:

 

  1. Trigger the onchange event on key input
  2. Assign the value of the textarea to propertyName, triggering its setter

 

Important here is the noEscape=true attribute. If not correctly set, it will that the value as a literal and always set “this.value” to propertyName. Hope this small bit will help you all a lot in your daily JSF struggles!


Tagged in: Java EE 6 , Java EE , Ajax4JSF , Ajax
Trackback(0)
Comments (0)Add Comment

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy

Tags:

Sponsers