Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops.

DockLayoutPanel doesn't work correctly??

1 min read

Suppose you'd like to create a layout like the following using GWT:

With GWT 2.0 the documentation suggests to use the DockLayoutPanel.
<g:DockLayoutPanel unit='EM'>
<g:north size='4'>
<g:Label>Header</g:Label>
</g:north>

<g:west size='16'>
<g:Label>Navigation</g:Label>
</g:west>

<g:center>
<g:ScrollPanel>
<g:Label>Content Area</g:Label>
</g:ScrollPanel>
</g:center>
</g:DockLayoutPanel>

However pay attention, this won't work if you use the standard mechanism like
public void onModuleLoad() {
RootPanel.get("main").add(new MainUI());
}
where the new MainUI() contains the DockLayoutPanel as root element (I assume you're using GWT's new UiBinder mechanism), then the DockLayoutPanel won't work surprisingly.

Instead you have to use
public void onModuleLoad() {
RootLayoutPanel panel = RootLayoutPanel.get();
panel.add(new MainUI());
}

Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus