2012-02-27 4 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) –

答えて

0

のようなものを見て、後で何とかそれを解決しました。

私は次のようにGWTでこれを使用しているグローバル共有限界

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

    } 

} 

を保持

私のクラス:

<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

関連する問題