Sunday, May 20, 2012

GWT use I18 Message resource in uiBinder

To use I18 Message resource in uiBinder you need to follow the same mechanism as that of ClientBundle

In your corresponding java class add @uiFactory method which will return the object of required Message interface e.g.

package com.test.module.client;

public interface Messages extends com.google.gwt.i18n.client.Messages {
 
  @DefaultMessage("Home")
  @Key("home")
  String home();
}

public class MyUiBinder extends Composite{
......
.....
.....

    @UiFactory
    public static Messages getResources() {
        return GWT.create(Messages.class);
    }
}


And you can use the same inside corresponding MyUiBinder.ui.xml file as

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:g='urn:import:com.google.gwt.user.client.ui'>

    <ui:with field='msg'
        type='com.test.module.client.Messages' />
    <g:HTMLPanel>
                 <g:Button text='{msg.home}'></g:Button>

    ......
    ......
    ......
    </g:HTMLPanel>
</ui:UiBinder>



Get New line after using float:left or right

To get new line after using float property on previous element. I found straight forward solution to use either "clear: both;" on next element.
e.g.
<div style="float: left;">
               ....
</div>
<div style="clear: both;">

               ....
</div>

for more details refer  http://www.positioniseverything.net/easyclearing.html