4

私は新しいアプリケーションに取り組んでおり、値を見つけるためにキーを使用してルックアップを備えたメッセージ インターフェイスを作成する必要があります (ConstantsWithLookup のようですが、パラメーターを受け取ることができます)。Dictionary クラスの機能を調査していますが、パラメーターによるメッセージのカスタマイズがありません。

ConstantsWithLookup を使用すると、次のことができます。

myConstantsWithLookupInterface.getString("key");

次のようなものを取得します。

Field must be filled with numbers

しかし、私はこれを行う必要があります:

myMessagesWithLookupInterface.getString("key", "param1", "param2",...);

次のようなものを取得します。

Field _param1_ must be filled with numbers greater than _param2_

これを行う方法がわかりません。

4

1 に答える 1

1

GWT正規表現を使用する:

//fields in your class
RegEx pattern1 = RegEx.compile("_param1_");
RegEx pattern2 = RegEx.compile("_param2_");

public String getString(String key, String replace1, String replace2){
    // your original getString() method
    String content = getString(key);
    content = pattern1.replace(content,replace1);
    content = pattern2.replace(content,replace2);
    return content;
}

データにが含まれている場合、これは文字列のコンテンツにField _param1_ must be filled with numbers greater than _param2_置き換えられます。_param1_replace1

于 2011-06-08T22:28:10.230 に答える