I have a Facelets page with a <table> (creating with <ui:repeat>). In each row of the <table> there is a <h:selectBooleanCheckbox>. I wanna add validation client have select at list one row. I use BalusC RequiredCheckboxValidator but, in that moment i have to click every checkbox in the page. Adding @Valid and @NotNull bean validation to map,not help either. How I can validate this?
<table >
<thead>
<tr>
<td>chekboxes</td>
...
</tr>
</thead>
<tbody>
<ui:repeat var="classroom" value="#{roomBean.classRooms}">
<tr><td>
<h:selectBooleanCheckbox value="#roomBean.checked[classroom.id]}"/>
</td>
...
</tr></ui:repeat>
</tbody>
</table>
<h:commandButton value="submit" action="#{bean.submit}" />
and
public class RoomBean{
private Map<Integer, Boolean> checked = new HashMap<Integer, Boolean>();
List<Integer> checkedClassRoomsID ;
//
public void submit() {
checkedClassRoomsID = new ArrayList<>();
for (ClassRoom classRoom : classRooms) {
if (checked.get(classRoom.getId())) {
checkedClassRoomsID.add(classRoom.getId());
}
}
}
// ...
}
Aucun commentaire:
Enregistrer un commentaire