Supposely, A4J makes it simple for a developer to apply Ajax capabilities on their current JSF applications. And I admit, it is. After a week trying on A4J, I've been able to make cool Ajax call between my client page and server.
Here is the problem. I have a simple form, where I display a name in two format. One with an <h:inputtext> tag and another one in the <h:outputtext> tag.

Very simple. Below is the code for each object on the page.

Input field code.

Text output code.

Reset button code.
As a conventional JSF way, I'd put 'immediate' attribute equals to 'true' for my <a4j:commandbutton>, in order to by pass the validation since the <h:inputtext> 'required' attribute is 'true'. The thing is, when I clicked on 'Reset' it only 'rerenders' the text output. Input field value, remains. Hmm. That's not right. It should clears off both, input and output objects.

Thanks to 'SergeySmirnov' from JBoss.com forum, he gaves a solution. Instead of using 'immediate' attribute to 'true', I should use <a4j:region> to surround my reset code like below.

As you can guess by now, it works. My reset buttons clears off both objects. By surrounding my reset button with <a4j:region>, it will only submit this particular region as an Ajax request and omits the others.

Yeah... A4J rules!
4 comments:
Man, I was looking a lot for this solution, and it easily works! Congratulations!
What I needed too! Thanx!
Wohoo, that saved my ass from rewriting my whole app. thanks!!
Thanks, it was what I needed
Post a Comment