Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you clear RootLayoutPanel in GWT?
    text
    copied!<p>I have Buttons attached to elements on the modules entrypoint html page using <code>RootPanel.get("foo").add(button)</code>. If I subsequently create a LayoutPanel and attach it using <code>RootLayoutPanel.get.add(layoutpanal)</code> then the buttons cannot be clicked. This is all fine. If I then try and remove the layoutpanel or clear the <code>RootLayoutPanel</code> the buttons still cannot be clicked.</p> <p>Any ideas how to clear this? Have I missed a step or should you simply never try and get back to using a page's <code>RootPanel</code> if you have used a <code>RootLayoutPanel</code>?</p> <p>Sample code:</p> <pre><code>public void onModuleLoad(){ final LayoutPanel lp1=new LayoutPanel(); ClickPanel ping=new ClickPanel("Ping"); ping.getElement().getStyle().setBackgroundColor( "#fdd" ); ping.addClickHandler( new ClickHandler(){ @Override public void onClick( ClickEvent event ){ Window.alert( "Ping!!!" ); //lp1.removeFromParent(); //RootLayoutPanel.get().remove(lp1); //RootLayoutPanel.get().removeFromParent(); RootLayoutPanel.get().clear(); } } ); ClickPanel bong=new ClickPanel("Bong"); bong.getElement().getStyle().setBackgroundColor( "#ddf" ); bong.addClickHandler( new ClickHandler(){ @Override public void onClick( ClickEvent event ){ Window.alert( "Bong!!!" ); } } ); lp1.add( ping ); lp1.setWidgetLeftWidth( ping, 100, Style.Unit.PX, 500, Style.Unit.PX ); lp1.setWidgetTopHeight( ping, 100, Style.Unit.PX, 500, Style.Unit.PX ); lp1.add( bong ); lp1.setWidgetLeftWidth( bong, 50, Style.Unit.PCT, 600, Style.Unit.PX ); lp1.setWidgetTopHeight( bong, 50, Style.Unit.PCT, 200, Style.Unit.PX ); Button b=new Button("Click Me"); b.addClickHandler( new ClickHandler(){ @Override public void onClick( ClickEvent event ){ RootLayoutPanel.get().add( lp1 ); } } ); RootPanel.get("button1").add( b ); } </code></pre> <p><code>ClickPanel</code> is simply overrides <code>HTMLPanel</code> implementing <code>HasClickHandelers</code>. Clicking "Click Me" opens the layout panel. Clicking the panel ping gets rid of the layout panel, but the button "Click Me" cannot be clicked. I've tried various options.</p> <p><strong>Update</strong></p> <p>Calling <code>RootPanel.get().remove(RootLayoutPanel.get())</code> removes the <code>RootLayoutPanel</code> clearing the LayoutPanel and allowing widgets on the RootPanel to be clickable. However it does causes something to get screwed up because any subsequent call to <code>RootLayoutPanel.get.add()</code> throws an <code>IndexOutOfBoundsException</code>. So this is not the full answer.</p>
 

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