PDA

View Full Version : HTMLTable getWidget/setWidget and ExtGWT Component



paulwang
11 Aug 2008, 3:25 PM
Hi,

I noticed that HTMLTable getWidget(int row, int column) always return null when the widget is a Ext GWT Component.

Looking at the code it looks like HTMLTable is relying on getWidgetIndex(Element elem) to return the __widgetID attribute of the elem for it to find the widget in widgetMap.

The problem occurs because Ext GWT Component getElement() method returns a dummy div when it's not rendered. It looks like the __widgetID is set on the dummy div but when you do a getWidget on HTMLTable it can't find the right widget since __widgetID is not set on the swapped in element.



final FlexTable foo = new FlexTable();

final LayoutContainer bar = new LayoutContainer();
bar.add(new HTML("<h1>HERE</h1>"));


RootPanel.get().add(foo);

foo.setWidget(0, 0, bar);
foo.setWidget(1, 1, new HTML("<h2>THERE</h2>"));

System.out.println(foo.getWidget(0, 0)); /* this is null but shouldn't be */
System.out.println(foo.getWidget(1, 1));

darrellmeyer
12 Aug 2008, 5:45 PM
Thanks for looking into the problem. I have changed the code in Component to grab and set the widget id from the dummy element. I also changed getElement to only create the dummy element once, not every call to getElement. The test code now works, changes are in SVN.

idajali
10 Jul 2009, 1:45 PM
Looks like they've changed it from "__widgetID" to "__uiObjectID" in GWT 1.6. Apparently they had two different ElementMapperImpl classes and they combined them (see http://www.mail-archive.com/google-web-toolkit-contributors@googlegroups.com/msg03129.html ).

Consequently, this bug has now been reintroduced in GXT 2.0 (running on GWT 1.6).

sven
10 Jul 2009, 5:01 PM
Changed in SVN