Append child Widget to parent Widget.. !! click handler of child Widget is not working .. ??

57 views
Skip to first unread message

Santosh kumar

unread,
Dec 18, 2010, 2:23:22 AM12/18/10
to google-we...@googlegroups.com
Hi,

Button button = new Button();
button.getElement().setAttribute("id", "buttonId");
SimplePanel simplePanel = new SimplePanel();
simplePanel.getElement().setAttribute("id", "childPanelId");
FlexTable flexTable = new FlexTable();
Button buttonInFlexTable = new Button();
buttonInFlexTable.addClickHandler(new ButtonInFlexTableHandler());
flexTable.setWidget(0, 0, buttonInFlexTable);
simplePanel.add(flexTable);
DOM.getElementById("buttonId").getParentElement().appendChild(simplePanel.getElement());
-
-
-
-
public class ButtonInFlexTableHandler implements ClickHandler {

  @Override
  public void onClick(ClickEvent event) {
    Window.alert("Hello ..!");
  }
}

According to this code, it should display the window alert message. But onClick of buttonInFlexTable button is not working !!

Please, any help is appreciated .. Thank you ..!!


--
Thanks & Regards

S a n t o s h  k u m a r .

 

Amir Kashani

unread,
Dec 19, 2010, 6:51:14 PM12/19/10
to google-we...@googlegroups.com
DOM.getElementById("buttonId").getParentElement().appendChild(simplePanel.getElement());
You can't attach a widget this way. Use RootPanel.get().add(simplePanel). Also, there's no need for the IDs -- reference the Widget objects rather than the elements within. If you want to intermix straight HTML and Widgets, use HTMLPanel or UiBinder.

Santosh kumar

unread,
Dec 22, 2010, 12:49:10 AM12/22/10
to google-we...@googlegroups.com
Hi, Amir

Thank you for your reply ... !!
Its working. i just added the code RootPanel.get("divId").add(simplePanel);        

          Button button = new Button();
          button.getElement().setAttribute("id", "buttonId");
          SimplePanel simplePanel = new SimplePanel();
          simplePanel.getElement().setAttribute("id", "childPanelId");
          FlexTable flexTable = new FlexTable();
          Button buttonInFlexTable = new Button();
          buttonInFlexTable.addClickHandler(new ButtonInFlexTableHandler());
          flexTable.setWidget(0, 0, buttonInFlexTable);
          simplePanel.add(flexTable);
          RootPanel.get("divId").add(simplePanel);
          DOM.getElementById("buttonId").getParentElement().appendChild(simplePanel.getElement());
Reply all
Reply to author
Forward
0 new messages