I have a JSF web app that uses ajax on a h:selectOneListbox to update another field on the screen with CSS. When I click the HTML "reset" button, the value in the h:selectOneListbox changes, but the ajax event doesn't fire.
Example: The h:selectOneListbox can contain values of USER, ACCT, NONE, EMAIL. I want to hide the Email input field and its label when "EMAIL" is not selected. As I change the drop down menu from value to value, it hides and shows the email fields as it should. If I start with "USER" selected and the email field hidden, then select "EMAIL" (which makes the email fields appear), then click the HTML "reset" button", the drop down menu changes back to "USER" but the email field is still visible. The ajax event to hide it hasn't fired.
You should use the "valueChange" event for the ajax call in your selectOneMenu and use "update=email emailLabel" instead of render. Then in the email and emailLabel, use render=<some condition> such the value in the selectOneMenu=email
From my experience render from such ajax calls sometimes doesn't work so an alternative is use disable instead. disable=false when selectOneMenu=email
The "reset" button renders as an HTML <INPUT TYPE="RESET"> control element. The HTML RESET button does not submit a form the way the SUBMIT button does. Instead, it initiates action within the client itself. The client (browser) will restore whatever values the related form had when the page was rendered.
Since AJAX is just a specialized type of form SUBMIT and RESET doesn't submit, that's why events don't fire and listeners are not invoked.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Jan 17, 2011
K. Tsang: I'm not sure what you mean. You want me to add another ajax field to the "email" inputText and "emailLabel" outputText fields? Did you want me to get rid of the conditional styleClass parameters? Something like this?