如何将标签绑定到支持类中的文本? [英] How to bind a label to text in backing class?

查看:39
本文介绍了如何将标签绑定到支持类中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将GWT标签绑定到视图的后备类中的字符串属性?

How can I bind a GWT label to a string property in the backing class for the view?

Login.ui.xml:
Welcome <g:Label text="{textFromJavaBackingClass}" />

class Login {
  String userName;
  String getUserName() { return userName; }
}

如何将值绑定到 String userName ?

推荐答案

假设您有一个i18n类 MyI18n ,该类扩展了 Messages

Let's say you have a i18n class MyI18n which extends Messages

只需包含以下内容

<ui:with field="i18n" type="MyI18n"/>

然后

Welcome <g:Label text="{i18n.textFromJavaBackingClass}" />

注意:实际上,MyI18n不需要扩展 Messages ,这只是调用任何no-arg方法的常用方法.

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}" />

这篇关于如何将标签绑定到支持类中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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