|
我有一个可本地化的GWT-Project的com.google.gwt.i18n.client.Messages实现.
但似乎不可能重载方法.这是一个Bug还是有原因的?
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)." )
String textValidatorError( String o );
}
提出来:
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}" .
最佳答案
您的Messages接口依赖于属性文件. 因为您的接口具有使用相同名称的方法,所以gwt会尝试在同一文件中查找属性textValidatorError两次. 它第一次寻找具有2个参数的属性,并找到它.第二次它正在寻找一个带有1个参数的属性,并找到一个有两个…因此错误.
使用@Key批注指定不同的属性名称.
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 );
}
(编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|