Searchable GWT Message Interface

I am working on a new application, and I need to do a search message interface using the key to find the value (e.g. ConstantsWithLookup, but capable of receiving parameters). I am studying the functionality of a dictionary class, but it lacks the message settings through the parameters.

With ConstantsWithLookup, I can do the following:

myConstantsWithLookupInterface.getString("key"); 

and get something like:

 Field must be filled with numbers 

But I need to do this:

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

and get something like:

 Field _param1_ must be filled with numbers greater than _param2_ 

I do not know how to do that.

+4
source share
1 answer

Use GWT regular expressions :

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

If your data contains Field _param1_ must be filled with numbers greater than _param2_ , then this will replace _param1_ with the contents of the replace1 string.

+1
source

All Articles