GWT UiBinder problem – LayoutPanel will not render

I wasted an hour on this one today trying to get my LayoutPanel to render so I figured it is worth sharing, if only for myself.

I am using UiBinder to create my UI and I wanted to use LayoutPanel to section my page into two halves.  I am using Eclipse with the GPE and created a new UiBinder class and file.  I then started making changes and ended up with this:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
    xmlns:g="urn:import:com.google.gwt.user.client.ui">
    <ui:style>
        /* Add CSS here. See the GWT docs on UI Binder for more details */
        .important {
            font-weight: bold;
        }
    </ui:style>
    <g:HTMLPanel>
    <g:LayoutPanel>
        <g:layer left="0" width="100">
            <g:Tree>
                <g:TreeItem ui:field="meterItem">
                    <g:TreeItem ui:field="moduleItem">
                        <g:InlineLabel text="Steve "/>
                        <g:InlineLabel text="Wall"/>
                    </g:TreeItem>
                </g:TreeItem>
            </g:Tree>
        </g:layer>
        <g:layer left="105" right="0">
            <g:Label text="This is where the meter properties will go."/>
        </g:layer>    
    </g:LayoutPanel>
    </g:HTMLPanel>
</ui:UiBinder>

When I ran my application and viewed this page in the browser, nothing would render.  I was so confused as it seemed like I had declared my LayoutPanel correctly, according to the GWT Javadoc.

Finally, I realized the problem.  I had declared my LayoutPanel INSIDE an HTMLPanel.  This was not necessary as I wanted the LayoutPanel to be responsible for the layout.  So I removed the declaration of the HTMLPanel, saved, refreshed my page in the browser and it worked!

Advertisements

About stevewall123

I am a Lead Software Engineer in Minneapolis working for Thomson Reuters. I am currently working on projects using Java, JavaScript, Spring, Drools, Hazelcast, Liquibase and Tomcat. Previously, I used C#, GWT, Grails, Groovy, JMS and JBoss Drools Guvnor. In the past I have worked on projects using J2EE, Swing, Webwork, Hibernate, Spring, Spring-WS, JMS, JUnit and Ant.
This entry was posted in GWT, UiBinder and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s