GWT - 在Java代码和UiBinder文件之间简单共享字符串和数字常量的最简单方法是什么? [英] GWT - What's the shortest way of simply sharing strings and number constants between Java code and UiBinder files?

查看:106
本文介绍了GWT - 在Java代码和UiBinder文件之间简单共享字符串和数字常量的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以发布一个在Java代码和UiBinder XML之间共享(最好是静态最终)字符串或数字常量的最短途径的示例,我可以在属性中使用常量:



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



或值:



< g:标签> ...< / g:标签>



我似乎无法找到这样的例子,只有来自文件的文本,我不想。

解决方案

static 字段(和枚举常量)可用于简单的< ui :import>

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

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

然后简单地:

 < g:标签文字={CONSTANT}/> 

 < g:标签>< ui:text from ={CONSTANT}/>< / g:标签> 

请参阅 https://code.google.com/p/google-web- toolkit / source / browse / trunk / user / test / com / google / gwt / uibinder / test / client / WidgetBasedUi.ui.xml#87


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆