I have created a Modal Window with several checkboxes. How do I validate at least one was checked?
public class ServicesModalPage extends AuthModalPage {
private AjaxButton commitBtn;
private AjaxButton cancelBtn;
final EntityTO selectedEntity = new EntityTO();
ServicesModalPage(final ModalWindow parentModalWindow, final EntityTO selectedEntity) throws VechsDatabaseException {
Form<EntityTO> form = new Form<EntityTO>("mainForm", new CompoundPropertyModel<EntityTO>(selectedEntity));
//ServicesModalPage(mainForm);
add(form);
//Form<EmptyFormTO> form = new Form<EmptyFormTO>("mainForm");
//add(form);
You might want to create an array of Checkbox labels and, for each label, add a new Checkbox object with the label to the form:
Assuming that your Form class has a method such as getComponents(), you might do something like this to determine if at least one Checkbox object is selected:
I hope this helps.