I have an com.google.gwt.i18n.client.Messages
implementation for a localizable GWT-Project.
But it seems that it is not possible to overload the Methods. Is it a Bug or is there a reason?
public interface CommonMessages extends Messages {
public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class );
@DefaultMessage( "The entered text \"{0}\" contains the illegal character(s) \"{1}\" ." )
String textValidatorError( String o, String e );
@DefaultMessage( "The entered text \"{0}\" contains ill开发者_JAVA技巧egal character(s)." )
String textValidatorError( String o );
}
brings up:
Rebinding common.client.i18n.CommonMessages
[java] Invoking generator com.google.gwt.i18n.rebind.LocalizableGenerator
[java] Processing interface common.client.i18n.CommonMessages
[java] Generating method body for textValidatorError()
[java] [ERROR] Argument 1 beyond range of arguments: The entered text "{0}" contains the illegal character(s) "{1}" .
Your Messages interface relies on a properties file. Because your interface has methods using the same name, gwt tries to look up the property textValidatorError twice in the same file. The first time it's looking for a property with 2 arguments, and finds it. The second time it's looking for a property with 1 arguments, and finds one with two ... Hence the error.
Use the @Key annotation to specify different property names.
public interface CommonMessages extends Messages {
public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class );
@DefaultMessage( "The entered text \"{0}\" contains the illegal character(s) \"{1}\" ." )
String textValidatorError( String o, String e );
@DefaultMessage( "The entered text \"{0}\" contains illegal character(s)." )
@Key("textValidatorErrorAlternate")
String textValidatorError( String o );
}
精彩评论