2012-02-27 59 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