Revision: 10182
Author:   jul...@google.com
Date:     Fri May 13 08:01:50 2011
Log: Attachable elements in UiBinder: always run logicalAdd(Attachable) for
Attachable widgets.

Before this patch, if we declared a <gwt:Attachable/> in the UiBinder template and a corresponding @UiField(provided=true) field in the Java class, no event
handlers were attached to the widget.

This happened because of a check in UiBinder's AttachableInterpreter. It invoked
logicalAdd only if the field derived from IsWidget, which is not the case of
Attachable. As we were declaring it only as an Attachable, it did not run
logicalAdd over it, so the event handlers were not installed.

logicalAdd(Attachable) does all type checks necessary. This patch makes UiBinder always produce code to logicalAdd(Attachable) the widget declared as <gwt:Attachable/> in the template, which causes the event handlers to get attached correctly.

Review at http://gwt-code-reviews.appspot.com/1446801

http://code.google.com/p/google-web-toolkit/source/detail?r=10182

Modified:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableInterpreter.java

=======================================
--- /trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableInterpreter.java Thu Apr 28 08:49:13 2011 +++ /trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableInterpreter.java Fri May 13 08:01:50 2011
@@ -67,14 +67,10 @@
         "%s.performDetachedInitialization();",
         fieldManager.convertFieldToGetter(childFieldWriter.getName()));

- // If this particular Attachable is a Widget, it needs to be added to the
-    // HTMLPanel.
-    if (uiWriter.isWidgetElement(elem)) {
-      fieldWriter.addDetachStatement(
-          "%s.logicalAdd(%s);",
-          fieldManager.convertFieldToGetter(fieldName),
-          fieldManager.convertFieldToGetter(childFieldWriter.getName()));
-    }
+    fieldWriter.addDetachStatement(
+        "%s.logicalAdd(%s);",
+        fieldManager.convertFieldToGetter(fieldName),
+        fieldManager.convertFieldToGetter(childFieldWriter.getName()));

// TODO(rdcastro): use the render() call that receives the SafeHtmlBuilder String elementHtml = fieldManager.convertFieldToGetter(childFieldWriter.getName()) + ".render("

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to