1

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!

scriptgeeky
  • 185
  • 1
  • 2
  • 8
  • Perhaps if I can fire off a javascript event that'll target the checkbox by id. That would certainly help as well. – scriptgeeky Jan 03 '12 at 23:16
  • So after some additional thought, I found a solution that worked. I did a for loop where I cast the first iteration as a flowPanel, then cast the second iteration again as a CheckBox. Finally setting the value to false. Hope that makes sense. – scriptgeeky Jan 04 '12 at 18:28

2 Answers2

1

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!

scriptgeeky
  • 185
  • 1
  • 2
  • 8
0

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).

Riley Lark
  • 20,660
  • 15
  • 80
  • 128