JSF h:selectManyCheckbox valueChangeEventListener not fired when user unchecks all
My problem is that when the user unchecks everything (leaving 0 checkboxes checked) JSF does not fire the valueChangeListener.
I appreciate any help, thanks.
JSPX:
<h:selectManyCheckbox
value="#{EME01.selectedMaterials}"
valueChangeListener="#{EME01.materialsValueChangeListener}"
onchange="submit();">
<f:selectItems value="#{EME01.materials}" />
</h:selectManyCheckbox>
开发者_开发问答Backing bean (EME01):
public void materialsValueChangeListener(ValueChangeEvent e) {
System.out.println("hello");
}
For checkboxes (and radio buttons) you're rather interested in click
event than the change
event.
onclick="submit()"
Unrelated to the concrete problem, consider using Ajax for this as it's pretty bad user experience to submit the entire form and have a flash of content on every change/click of the checkbox. If you're already on JSF2 for example, use <f:ajax>
instead.
精彩评论