Reputation: 29
Can someone tell me why the valueChangeListener method is never fired?
<h:form>
<h:selectBooleanCheckbox
value="#{reaCtrl.update}"
valueChangeListener="#{reaCtrl.updateC}" onclick="submit()">
</h:selectBooleanCheckbox>
</h:form>
The method updateC looks like that:
public void updateC(ValueChangeEvent event) {
System.out.println("testC");
}
Thx
Upvotes: 1
Views: 8620
Reputation: 1
Do like this:
<h:selectBooleanCheckbox value="#{reaCtrl.update}">
<p:ajax event="change" partialSubmit="true" process="@this"/>
</h:selectBooleanCheckbox>
Upvotes: -1
Reputation: 5031
Your updateC
method will be invoked by the JSF implementation after the Process Validation Phase, so my guess is that you have some other validation errors which causes that your method is never invoked.
You can place <h:messages/>
tag in start of your form to display all conversion / validation errors.
However, in case you want to bypass that validation, you can use the immediate
attribute like this:
<h:selectBooleanCheckbox
value="#{reaCtrl.update}" immediate="true"
valueChangeListener="#{reaCtrl.updateC}" onclick="submit()">
</h:selectBooleanCheckbox>
Adding that attribute will fire a Value Change events after Apply Request Values Phase, which means that your method updateC
will be invoked in that phase, after the method xecutes you should skip to the Render Response Phase, so you need to modify your method like this:
public void updateC(ValueChangeEvent event) {
System.out.println("testC");
FacesContext context = FacesContext.getCurrentInstance();
context.renderResponse();
}
Upvotes: 2