2012-02-27 44 views
1

我有一个静态变量类,如 public static String MENU =“menu1”; 我如何访问ui.xml中这些变量的值?如何使用ui.xml访问静态变量

要访问方法我看到的东西像

+0

可能[如何将标签绑定到支持类中的文本?](http://stackoverflow.com/questions/17109363/how-to-bind-a-label-to-text-in-backing-class) – 2015-02-13 13:33:52

回答

0

我发现这个问题并解决它在某种程度上更高版本。

我抱着类的全局共享范围

/** 
* 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