read

This is just a quick post in the hope that I can help others avoid hours debugging an “issue” I recently had. I was working through a new application that I’m building using the new MVP framework in GWT 2.1, and for the life in me couldn’t understand why the LayoutPanel I was adding to the page was not invisible. The code could be as simple as this.

I could clearly see it was added to the DOM when I poked around with Web Inspector, but it just wasn’t visible. I made sure my HTML doctype was set to standards mode. Dumbfounded, I went to the GWT documentation on Panels, and sure enough, found the RootLayoutPanel. *LayoutPanels need to be added to the RootLayoutPanel, not the RootPanel.

Works perfectly.

I found this hidden/invisible issue comes up with most *LayoutPanel panels added to RootPanel. The same effect is experienced when you stick these panels into an HTMLPanel, as is customary when writing UiBinder code.

Of course, the previously mentioned GWT documentation clearly states at the end.

When should I not use layout panels?

The panels described above are best used for defining your application’s outer structure — that is, the parts that are the least “document-like”. You should continue to use basic widgets and HTML structure for those parts for which the HTML/CSS layout algorithm works well. In particular, consider using UiBinder templates to directly use HTML wherever that makes sense.

The documentation points out the misuse of *LayoutPanel. However, I was thinking a good usability feature would be to display a warning that the *LayoutPanel is being abused. This warning should probably be in Development Mode. If you’d like to see something along those lines, please star the issue I created

Blog Logo

Arthur Maltson


Published

Image

Technical Dev Blog

Technical development blog of Arthur Maltson. Covers many topics from Java to Ruby to DevOps.

Back to Overview