vendredi 29 mai 2015

validate selected checkboxes in listview wicket

How can I validate that not more than one checkbox is selected in a listview (repeater)?

I have a Form with a ListView in Wicket with following structure:

line 1 to n: AjaxCheckBox and TextField

Both elements are connected by CompoundPropertyModel<SimpleType>. POJO SimpleType looks like:

public class SimpleType {
   private boolean selected;
   private String value;

   Getter/Setter...
}

If more than one checkbox is selected, form should reject any changes. So the user must deselect the selected checkbox first before he can choose another checkbox. I tried with surrounded CheckGroup with IValidator<Collection<SimpleType>>, but I need to change AjaxCheckBox to component Check. In this case Check seems to be not updated with state selected from CompoundPropertyModel.

Do I really need a Validator or Visitor for this case? How to implement them?




Aucun commentaire:

Enregistrer un commentaire