开发者

Problem using GWT-VL?

I'm trying to evaluate GWT validation library with a very si开发者_如何学运维mple example taken from the author site. and here is a code snippet

validator.addValidators( "birthYear",new IntegerValidator(schoolName_txt, 1890, 2009)
                .addActionForFailure(new StyleAction("validationFailedBorder"))
                .addActionForFailure(new LabelTextAction(error_label))
                );

but the problem is that when I run the application I got the following error:

no property localization given for key: birthYear

but I'm sure that I have included this key in my localization files,so what is this?

Thanks


To get rid of this error message you have to extend ValidationMessages:

import eu.maydu.gwt.validation.client.i18n.ValidationMessages;
public class CustomValidationMessages extends ValidationMessages {
  @Override
  public String getPropertyName(String propertyName) {
    return propertyName;   // This just returns the property name instead of the error message
  }
}

Then change pass an instance of this class to the ValidationProcessor instance instead of just an empty parameter:

ValidationProcessor validator = new DefaultValidationProcessor(new CustomValidationMessages());

The purpose of this I suppose to give you a chance to change the displayed input name in the error message if your app is multi-language.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜