Hello, I have a field validator. I want to be able to choose if it will be an error (blocking the action) or a warning (just display a non-blocking warning).
Here is the code I use, that is working except the error/warning is not localized: public class ValidatorWithWarningOption implements IValidator<String> { final private TextField<String> field; final private boolean warning; public ValidatorWithWarningOption(TextField<String> field, boolean warning) { this.field = field; this.warning = warning; } @Override public void validate(IValidatable<String> validatable) { String error = null; if(/*condition for error*/) { error = "The field " + field.getLabel().getObject() + " is not well formatted."; } if( errors != null ){ if( this.warning ){ field.warn( error ); }else{ field.error( error ); } } } } 1/ Am I using the framework properly ? There might be a better way to do it. Idealy, if it'd exist, I would have used a method such as validatable.warn(IValidationError error) (like validatable.error(IValidationError error)), so I would not have to pass the field itself to the class and I would get proper localized warning, as I get for errors. Is there a way to do it ? 2/ If I set the error like this: ValidationError error = new ValidationError( this, "ERROR" ); (with "ValidatorWithWarningOption.ERROR = The field ${label} is not well formatted." in the properties files) => For field.error( error ); I get a proper localized message (This call the method error(IValidationError error) from FormComponent) => But for field.warn( error ); I don't. As FormComponent has no method warn, this calls Component.warn(final Serializable message) so there is no localization handeling at all. How can I get my warnings localized ? Thanks for any help ! --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org