GWT target CheckBox widget within a flow panel

533 Views Asked by At

I have a CheckBox widget within a flowpanel, which is also within a flowpanel. Essentially, what I have is the following:

<div class="flowPanel1">
   <div class="flowPanel2">
      <checkBox>
   </div>
   <div class="flowPanel2">
      <checkBox>
   </div>
   <div class="flowPanel2">
      <checkBox>
   </div>
</div>

What i'd like to do is that when an anchor is clicked, I can uncheck the checkbox one I need unchecked. Keeping in mind that i'm generating the code above through a for loop using the checkbox value/id from an arrayList from a database. Hope that makes sense, thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

For those interested, here's what I did:

for (int j = 0; j < checkBoxList.size(); j++){
    if(checkBoxList.get(j) == checkBoxId){
    FlowPanel subFlowPanel = (FlowPanel) mainFlowPanel.getWidget(j);
    CheckBox checkBox = (CheckBox) subFlowPanel.getWidget(0);
    checkBox.setValue(false);
    }
}

Thanks!

PS. If you know a better way of achieving the same result, let me know. Thanks!

0
On

If you're already using GWT, I'd recommend generating CheckBox instances instead of rendering the HTML yourself. Then you can use CheckBox.setValue(true) to check a checkbox programatically (e.g. when an Anchor is clicked).