如何将 GWT 标签绑定到视图支持类中的字符串属性?
Login.ui.xml:
Welcome <g:Label text="{textFromJavaBackingClass}" />
class Login {
String userName;
String getUserName() { return userName; }
}
如何将值绑定到String userName
?
在xml中声明类
<ui:with field="myclass" type='package.ClassName' />
在 Ui 活页夹中写入
g:Label text='{myclass.getUsername}'></g:Label>
这是未来的参考
Let's say you have a i18n class MyI18n
which extends Messages
Just include the following
<ui:with field="i18n" type="MyI18n"/>
Then
Welcome <g:Label text="{i18n.textFromJavaBackingClass}" />
Note : MyI18n is actually not required to extends Messages
, this is just the common way to call any no-arg method.
<ui:with field="clazz" type="AnyClass"/>
Welcome <g:Label text="{clazz.anyMehtodWhichDoesNotTakeArgs}" />