Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll start with the fix, then move on to explain it afterward.</p> <h1>Fixing the problem</h1> <p>The easiest way to fix this problem is as follows. Here's your code:</p> <pre><code>HTMLPanel innerPanel = reference.getRefPanel(); innerPanel.getElement().setId(HTMLPanel.createUniqueId()); referencePanel.add(innerPanel); </code></pre> <p>Replace that with the following code. Note that only the last line has changed.</p> <pre><code>HTMLPanel innerPanel = reference.getRefPanel(); innerPanel.getElement().setId(HTMLPanel.createUniqueId()); referencePanel.add(reference); </code></pre> <p>This way, you are adding the <code>Composite</code> object. There will be no difference to the user, as the <code>HTMLPanel</code> (your <code>innerPanel</code>) will be directly attached into the document.</p> <hr> <h1>Some background</h1> <h2>Adding a widget to a complex panel</h2> <p>When you add a widget to a complex panel (a panel that holds more than one child widget), four things happen one after the other:</p> <ol> <li><strong>The widget is told to remove itself from its current parent</strong></li> <li>The panel adds the widget to its list of children</li> <li>The panel adds the widget to the document</li> <li>The widget is told to set the panel as its new parent</li> </ol> <h2>Telling a widget to remove itself from its parent</h2> <p>When a child is told to remove itself from its parent, one of the following occurs:</p> <ul> <li>If the widget does not have a parent, it does nothing</li> <li>If the widget is the child of a panel that implements <code>HasWidgets</code>, the widget tells the panel to remove that widget</li> <li><strong>Otherwise, the widget throws <code>IllegalStateException</code> with message "This widget's parent does not implement HasWidgets</strong></li> </ul> <h2>Composite widgets</h2> <p>When calling <code>initWidget(Widget)</code>, the widget's parent is set to the <code>Composite</code> object.</p> <h1>The problem</h1> <p>When you try to add <code>innerPanel</code>, it is told to remove itself from its current parent. <code>innerPanel</code> is actually the root of your UiBinder template. Its parent is a <code>Composite</code> object (specifically, <code>ReferenceUI</code>). This results in the exception being thrown, as <code>Composite</code> does not implement <code>HasWidgets</code> and does not support removing its widget.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload