yeah, because GWT not support java.text.Collator (and java.util.Locale also) ;/
Any solutions?
I found this solution which uses javascript. This is because GWT doesn't support Collator.
http://osdir.com/ml/GoogleWebToolkit/2009-06/msg01572.html
public class Collator {
public static final Collator getInstance() {
return instance;
}
private static final Collator instance = new Collator();
public native int compare( String source, String target ); /*-{
return source.localeCompare( target );
}-*/
}
I have never used it personally, but it looks promising. You might have to make changes so that there are no cross browser issues.
Edit:
Read up on JSNI.
This allows GWT to invoke raw "javascript" code within your Java code. This is what we are doing in the above class. The method "compare" makes a native call to javascript.
http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#writing
Add Collator.java to your current work space.
You should be able to compare as follows.
Collator customCollator = Collator.getInstance();
if ( customCollator.compare( srcString , targetString ) > 0 )
{
//the compare method will return an int.
// write your code here.
}
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With