GWT - 在Java代码和UiBinder文件之间简单共享字符串和数字常量的最简单方法是什么? [英] GWT - What's the shortest way of simply sharing strings and number constants between Java code and UiBinder files?
问题描述
有人可以发布一个在Java代码和UiBinder XML之间共享(最好是静态最终)字符串或数字常量的最短途径的示例,我可以在属性中使用常量:
< g:TextArea width =... px/>
或值:
< g:标签> ...< / g:标签>
我似乎无法找到这样的例子,只有来自文件的文本,我不想。
< ui :import>
:
< ui:import field =com.example.Pojo.CONSTANT />
或
< ui:import field =com.example.Pojo。*/>
然后简单地:
< g:标签文字={CONSTANT}/>
或
< g:标签>< ui:text from ={CONSTANT}/>< / g:标签>
Can someone post an example of the shortest way of sharing a (preferably static final) string or number constant between Java code and UiBinder XML, where I can use the constant either in an attribute:
<g:TextArea width="...px"/>
or in a value:
<g:Label>...</g:Label>
I can't seem to find an example of this, only text from a file, which I don't want.
static
fields (and enum 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 simply:
<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.
这篇关于GWT - 在Java代码和UiBinder文件之间简单共享字符串和数字常量的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!