google-code-export / gwt-ext

Automatically exported from code.google.com/p/gwt-ext
0 stars 0 forks source link

Function ContentPanel.add(Widget w) doesn't work correct. (included code to fix it) #116

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Here is the code to view the diferent behaviour:
public void onModuleLoad() {
        ContentPanel cp = new ContentPanel("test1");
        cp.setContent("test", true);
        RootPanel.get().add(cp);
        GWT.log("First one: " + cp.getElement().toString(), null);

        cp = new ContentPanel("test2");
        cp.add(new Label("test"));
        RootPanel.get().add(cp);
        GWT.log("Second one: " + cp.getElement().toString(), null);
}

Here it is the log output:
-----
First one: 
    <DIV id=test1>
        <DIV id=test1-content>test<SPAN id=ext-gen8></SPAN></DIV>
    </DIV>
-----
Second one:
    <DIV id=test2>
        <DIV id=test2><!-- label must be here --></DIV>
        <DIV class=gwt-Label __eventBits="131197" onchange="null" onload="null"
onerror="null">test</DIV>
    </DIV>
-----

I fixed it in this way
    public void add(Widget w) {
        add(w, DOM.getFirstChild(getElement()));
//        add(w, getElement());
    }

Here is the patch:
Index: ContentPanel.java
===================================================================
--- ContentPanel.java   (revision 577)
+++ ContentPanel.java   (working copy)
@@ -157,7 +157,8 @@
     }-*/;

     public void add(Widget w) {
-        add(w, getElement());
+        add(w, DOM.getFirstChild(getElement()));
+//        add(w, getElement());
     }

     public native void destroy() /*-{

Original issue reported on code.google.com by or...@newmail.ru on 14 Sep 2007 at 1:15

GoogleCodeExporter commented 9 years ago

Original comment by sanjiv.j...@gmail.com on 20 Sep 2007 at 7:09