aspose file tools*
The moose likes JSF and the fly likes Ajax Listener event valueChange seems to be firing onClick instead of onChange Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Ajax Listener event valueChange seems to be firing onClick instead of onChange" Watch "Ajax Listener event valueChange seems to be firing onClick instead of onChange" New topic
Author

Ajax Listener event valueChange seems to be firing onClick instead of onChange

Jessie Mohr
Greenhorn

Joined: Oct 24, 2011
Posts: 9
I have a nested list of Questions that I'd like to display. Initially, I'm displaying the Level 1 questions and then subquestions are displayed based on the users answers to the their parent question. All questions have a radio button and some questions have an input box for additional information that is shown when user selects "Yes"

Here is my JSF code with nested dataTables. Please note that I have pulled out formatting of these questions in order to simply the question on the forum, so these may look "unpretty" if you copy this code into your own environment and run the code:



Here is the code for the reset function on the backing bean:



Here is the problem:

The ajax event should default to "valueChange". If I click on "Yes" and then "Yes" again, the ajax call should not happen, correct? But it is, as the Additional Info box is clearing out based on the reset function.

I had originally tried adding a condition to the reset function to check the value of the button that was clicked and only reset the addnInfo value and subquestions if the answer is "0" (No). But this was causing issues with the rendering as the ajax call would render the input box and subquestions to hide and the value would be held onto on the front end, even though they're reset on the backing bean. When they re-rendered to the front in, the value that was held onto shows up instead of the value in the backing bean.

Another attempt was using a ValueChangeListener for the reset of the values. But this still has the same issue with the value being held onto when re-rendering.

I have tried 3 different approaches (listed above) and all have failed. I'm open to hearing a solution to any of these or possibly another solution. Keep in mind that formatting limitations by the users leaves me with less options to work with.

Also note that this needs to be IE Compatible. Change the event to "change" causing IE to not work as it needs an additional click to fire the ajax.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax Listener event valueChange seems to be firing onClick instead of onChange