Reputation: 1317
I have 3 checkboxes, so I have 3 different IDs. I need at least one checkbox checked by the user. I have defined an error message only for the first ID, so if the user leaves all 3 checkboxes unchecked, he will see my error message and the first checkbox will be marked yellow.
Now I want to mark all 3 checkboxes yellow when none is checked. This is possible with 3 error messages for each ID. But the unwanted side effect is that the users then sees 3 error messages. I want only one error message and 3 yellow checkboxes. It this possible in JSF?
Upvotes: 1
Views: 946
Reputation: 1108722
This has basically 2 solutions:
Either use a single <h:selectManyCheckbox>
instead of <h:selectBooleanCheckbox>
es, so that you can simply set required="true"
on it:
<h:selectManyCheckbox ... required="true">
...
</h:selectManyCheckbox>
Or use <o:validateOneOrMore>
of OmniFaces:
<h:selectBooleanCheckbox id="one" ... />
<h:selectBooleanCheckbox id="two" ... />
<h:selectBooleanCheckbox id="three" ... />
<o:validateOneOrMore components="one two three" />
Upvotes: 4