GWT access style defined inside .ui.xml within corresponding .java file

Some times you may want to access styles defined inside your Sample.ui.xml file which you want to access/use from within Sample.java widget class. You can do that by defining an interface which extends from com.google.gwt.resources.client.CssResource and declaring method with name matching exactly that of required style class name that you have declared inside ui.xml. Refer below code. Sample.ui.xml contents <src path>/com/pandurang/client/ui/Sample.ui.xml <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'> . . . <ui:style type="com.pandurang.client.ui.Sample.MyStyle"> .domain { margin: 0 auto; width: 730px; } . [Read More]

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") @DefaultMessage("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. [Read More]