CheckBoxMultipleChoice with CheckGroup

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CheckBoxMultipleChoice with CheckGroup

craliaga
I implemented CheckBoxMultipleChoice with items at run time, now I need to complete with an option to mark all. I have used the CheckGroup but apparently it is not working, any advice is welcome.

Here is my html code:

<input type="checkbox" wicket:id="groupselector"> check/uncheck all </input>
<div class="modal-body">
    <div class="row-fluid">
        <div class="clearfix">
            <div wicket:id="contratos"></div>
        </div>
    </div>
   </div>


And java code:
Form<ContratoList> formData;
    add(formData = new Form<>("formulario", new CompoundPropertyModel<>(contratoListIModel)));
    CheckGroup group = new CheckGroup("group");
    group.add(new CheckGroupSelector("groupselector"));
    group.add(new CheckBoxMultipleChoice<>("contratos",
            TipoServicio.getTodos(), TipoServicio.getCR()).
            setOutputMarkupId(true)); /* Here get items, works fine*/
    formData.add(group);
Reply | Threaded
Open this post in threaded view
|

Re: CheckBoxMultipleChoice with CheckGroup

craliaga
And the answer is:
HTML
<div class="modal-body">
    <div class="row-fluid">
        <input type="checkbox" wicket:id="group"> Marcar todos </input>
    </div>
    <div style="display:inline-block;  width: 50px;">
       
    </div>
</div>
Java
Form<ContratoList> formData;
add(formData = new Form<ContratoList>("formulario", new CompoundPropertyModel<ContratoList>(contratoListIModel)));
CheckBoxMultipleChoice ddc = new CheckBoxMultipleChoice<String>("contratos",
    TipoServicio.getTodos(), TipoServicio.getCR());
formData.add(ddc.setOutputMarkupId(true));
CheckboxMultipleChoiceSelector cbmcs = new CheckboxMultipleChoiceSelector("group", ddc);
formData.add(cbmcs).setOutputMarkupId(true);