title: How to dynamically add views in GWT?
body: <p>I have a template View called PageShell that allows me to define a page structure for all the pages in my app. When a new page presenter is created it will create a PageShell view and set the menu and main views.</p>
  
  <p>PageShell.ui.xml
      
      </p>
  
  <pre><code>&lt;ui:style&gt;
  .pageMenuDiv {
      height:100%;
      width:200px;
      float:left;
      margin:0px;
      padding:0px;
  }
  .pageMainDiv {
      height:100%;
      margin:10px;
      padding:0px;
      margin-left:200px;
  }
  .pageContainer {
      margin:0px;
      padding:0px;
  }
  &lt;/ui:style&gt;
  
      &lt;g:HTMLPanel ui:field="pageContainer"&gt;
      &lt;div id="pageMenuDiv" class="{style.pageMenuDiv}"/&gt;
      &lt;div id="pageMainDiv" class="{style.pageMainDiv}"/&gt;
      &lt;/g:HTMLPanel&gt;
  &lt;/ui:UiBinder&gt; 
  </code></pre>
  
  <p>I run into problems when trying to dynamically add the views to the 2 DIVs above by using either add(menuView, "pageMenuDiv") or addAndReplaceElement (no errors but the newly inserted views do not show up).</p>
  
  <p>However, it works fine if instead of DIVs I use:</p>
  
  <pre><code>&lt;g:HTMLPanel styleName="{style.pageContainer}" width="100%" height="100%"&gt;
      &lt;g:SimplePanel ui:field="pageMenuContainer" styleName="{style.pageMenuDiv}"/&gt;
      &lt;g:SimplePanel ui:field="pageMainContainer" styleName="{style.pageMainDiv}"/&gt;
  &lt;/g:HTMLPanel&gt;
  </code></pre>
  
  <p>What is the right approach to achieve this?
  Thanks,
  Sebastian</p>