You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Bertrand Guay-Paquet (Commented) (JIRA)" <ji...@apache.org> on 2012/02/09 19:33:59 UTC
[jira] [Commented] (WICKET-2244) Allow overriding of the Validator
default MessageKey
[ https://issues.apache.org/jira/browse/WICKET-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204716#comment-13204716 ]
Bertrand Guay-Paquet commented on WICKET-2244:
----------------------------------------------
This commit broke the validator messages for classes extending MaximimumValidator, MinimumValidator, and RangeValidator.
To reproduce, go to wicket-examples/dates and submit an invalid "hours" value (e.g. -2) in the "Example using DateTimeField".
Prior to this, the resource key was set to a hard coded value. Now it is Classes.simpleName(getClass()). DateTimeField uses a custom RangeValidator subclass (HoursValidator) so it can't find the resource key anymore.
I think it would be prudent to use the previously hard coded key values in the new resourceKey() method so subclasses not wanting to override the default message key can still use it.
> Allow overriding of the Validator default MessageKey
> -----------------------------------------------------
>
> Key: WICKET-2244
> URL: https://issues.apache.org/jira/browse/WICKET-2244
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4-RC2
> Reporter: Alexandru Objelean
> Assignee: Martin Grigorov
> Fix For: 1.5.2
>
>
> Currently there is no other way to change the default message key of any validator. Provide a protected non final method: getMessageKey() to allow overriding of the message key. For example for MinimumValidator:
> [CODE]
> public void validate(IValidatable<Z> validatable)
> {
> Z value = validatable.getValue();
> if (value.compareTo(minimum) < 0)
> {
> ValidationError error = new ValidationError();
> error.addMessageKey(getMessageKey());
> error.setVariable("minimum", minimum);
> validatable.error(error);
> }
> }
> protected String getMessageKey() {
> return "MinimumValidator";
> }
> [CODE]
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira