【问题标题】:how to access static variables using ui.xml如何使用 ui.xml 访问静态变量
【发布时间】:2012-02-27 10:30:31
【问题描述】:

我有一个包含一些静态变量的类,例如 公共静态字符串菜单=“菜单1”; 如何访问 ui.xml 中这些变量的值?

要访问方法,我看到了类似

【问题讨论】:

标签: uibinder


【解决方案1】:

我发现了这个问题,后来以某种方式解决了。

我的班级持有全局共享限制

/**
 * Class to hold shared limits for input fields
 */
public final class InputLimits {
    /**
     * private constructor that prevent instantiation.
     */
    private InputLimits() {

    }


    public static final int MAX_LENGTH = 10;

    /**

     * @return max length for GWT (is resolved at compile time no instance of class needed only method declaration)

     */

public static final int getMaxLength() {

    return MAX_LENGTH;

    }

}

我在 GWT 中以下列方式使用它:

<ui:with field="InputLimits" type="....InputLimits"/>
<g:TextBox ui:field="text" maxLength="{InputLimits.getMaxLength}" />

官方 GWT 文档应该在这里: http://www.gwtproject.org/doc/latest/DevGuideUiBinder.html#Hello_Text_Resources

【讨论】:

    猜你喜欢
    • 2017-11-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 2015-07-22
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多