GWT - What is the shortest way to easily exchange strings and number constants between Java code and UiBinder files?

Can someone post an example of the shortest way to exchange (preferably a static finite) string or a number constant between Java code and UiBinder XML, where I can use a constant either in an attribute:

<g:TextArea width="...px"/>

or meaning:

<g:Label>...</g:Label>

I can not find an example of this, only text from a file that I do not want.

+4
source share
1 answer

static fields (and enumeration constants) can be used with a simple <ui:import> :

 <ui:import field="com.example.Pojo.CONSTANT" /> 

or

 <ui:import field="com.example.Pojo.*" /> 

and then just:

 <g:Label text="{CONSTANT}" /> 

or

 <g:Label><ui:text from="{CONSTANT}"/></g:Label> 

See https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml#87 for an example.

+9
source

All Articles