Search code examples
gwtuibinder

HTMLPanel.wrap() assert fails


I'm using UiBinder to create a custom widget. The UI template is something like:

<g:HTMLPanel styleName="setting">
    <div ui:field="dynamicDiv">
    </div>
    {other stuff here}
</g:HTMLPanel>

Then, to add widget in the dynamicDiv I wrap it with HTMLPanel:

HTMLPanel.wrap(dynamicDiv);

and just use it as a normal widget.

When I run the application normally everything is fine, but if I run in debug mode, the following

assert Document.get().getBody().isOrHasChild(element);

in HTMLPanel.wrap() it fails, hence I am unable to debug the code.

Apart from the annoyance of debugging, I guess there was a good reason to put that assert there, so I would like to understand what is the correct way to wrap that div.


Solution

  • You don't need to wrap the div, just use the appropriate method from the containing HTMLPanel; e.g.:

    theHtmlPanel.add(theWidget, dynamicDiv);