gwt get array button value

Posted by graybow on Stack Overflow See other posts from Stack Overflow or by graybow
Published on 2010-06-14T11:21:42Z Indexed on 2010/06/15 4:22 UTC
Read the original article Hit count: 204

Filed under:

My gwt project have flexTable show data of image and button on each row and coll.
But my button won't work properly. this is my current code:

private Button[] b = new Button[]{new Button("a"),...,new Button("j")};
private int z=0;
...
public void UpdateTabelGallery(JsArray str){
    for(int i=0; i str.length(); i++){
    b[i].setText(str.gettitle());                               
    UpdateTabelGallery(str.get(i));                   
  }
}

public void UpdateTabelGallery(GalleryData str){
  Image img = new Image();  
  img.setUrl(str.getthumburl());  

  HTML himage= new HTML("a href="+str.geturl()+">"+ img +"/a>" + b[z] );                                                        
  TabelGaleri.setWidget(y, x, himage);

//is here th right place?
  b[z].addClickHandler(new ClickHandler(){
  @Override
    public void onClick(ClickEvent event) {
      Window.alert("I wan to show the clicked button text" + b[z].getText());               
    }                         
  });

  z++;
}



I'm still confuse where I should put my button handler. With this current code seems the clickhandler didn't work inside a looping. And if I put it outside loop its not working because I need to know which button clicked. I need to get my index button.but how? Is there any option than array button?

thanks

© Stack Overflow or respective owner

Related posts about gwt