GWT Dynamic checkboxes in UiBinder

607 views Asked by At

How to implement GWT Dynamic checkboxes in UiBinder. enter image description here

Here is my requirement: I should implement Dynamic checkboxes. The marked check boxes are not fixed, there may be more or less of them. By using <gwt:CheckBoxGroup ui:field="group1">, I can implement fixed check boxes with static data like this.

                    <m:CheckBoxGroup ui:field="group2">
                        <m:CheckBox>11/17/2016</m:CheckBox>
                        <m:CheckBox>11/15/2016</m:CheckBox>
                        <m:CheckBox>11/14/2016</m:CheckBox>
                        <m:CheckBox>11/11/2016</m:CheckBox>
                    </m:CheckBoxGroup>

Can you help me implementing Dynamic checkboxes in uibinding.

1

There are 1 answers

0
Adam On

UiBinder is just a declarative XML template. In the docs you will find:

It is not a renderer, or at any rate that is not its focus. There are no loops, no conditionals, no if statements in its markup, and only a very limited expression language. UiBinder allows you to lay out your user interface. It’s still up to the widgets or other controllers themselves to convert rows of data into rows of HTML.

So you need to add your checkboxes to the CheckBoxGroup with Java code:

@UiField
CheckBoxGroup group1;

...

CheckBox check1 = new CheckBox();
check1.setBoxLabel("11/17/2016");

...

group1.add(check1);
group1.add(check2);
group1.add(check3);

More examples here.