You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sylvain Vieujot (JIRA)" <ji...@apache.org> on 2011/07/08 13:58:16 UTC

[jira] [Created] (WICKET-3879) Support FormValidator and package level resource bundles

Support FormValidator and package level resource bundles
--------------------------------------------------------

                 Key: WICKET-3879
                 URL: https://issues.apache.org/jira/browse/WICKET-3879
             Project: Wicket
          Issue Type: Improvement
          Components: wicket-core
            Reporter: Sylvain Vieujot
            Assignee: Igor Vaynberg


Basically allow the following to work:

public class MyValidator extends AbstractValidator {
   protected void onValidate(IValidatable v) {
       error(v);
   }
}

MyValidator.properties
MyValidator=${label} is invalid

MyValidator_nl.properties
MyValidator=${label} is niet goed

Igor also asked for package level resource bundles

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-3879) Support FormValidator and package level resource bundles

Posted by "Sylvain Vieujot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13061919#comment-13061919 ] 

Sylvain Vieujot commented on WICKET-3879:
-----------------------------------------

It seems WICKET-1103 solve the issue for a Validator attached to a field, but it does not work for an AbstractFormValidator.
A FormValidator usually reports an error to one of the Form's field.

Example :
public class NewUserValidator extends AbstractFormValidator {

	private final EmailTextField loginField;

	public NewUserValidator(EmailTextField loginField) {
		this.loginField = loginField;

		if( loginField == null )
			throw new IllegalArgumentException( "argument loginField cannot be null" );
	}

	@Override
	public FormComponent<?>[] getDependentFormComponents() {
		return new FormComponent[] { loginField };
	}

	@Override
	public void validate(@SuppressWarnings( "unused" ) Form<?> form) {
		final String login = loginField.getValue();

		if( StringUtils.isNotBlank( login )) {
			WebUser sameLogin = new WebUserDAO().getByLogin( login );
			if( sameLogin != null )
				error( loginField );
		}
	}
}

Reports an error message :
Could not locate error message for component: EmailTextField@joiningForm:login and error: [ValidationError message=[null], keys=[NewUserValidator], variables=[[label0=login],[name0=login],[input0=wer@toto.com]]]. Tried keys: login.NewUserValidator, NewUserValidator.

The reason seems to be that an AbstractFormValidator is not attached to a Field, and ValidatorStringResourceLoader looks in the form component's behaviours.
But as the validator is a form validator, it is not in the component's behaviours :
See ValidatorStringResourceLoader, line 81 to 90.

> Support FormValidator and package level resource bundles
> --------------------------------------------------------
>
>                 Key: WICKET-3879
>                 URL: https://issues.apache.org/jira/browse/WICKET-3879
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-core
>            Reporter: Sylvain Vieujot
>            Assignee: Igor Vaynberg
>
> Basically allow the following to work:
> public class MyValidator extends AbstractValidator {
>    protected void onValidate(IValidatable v) {
>        error(v);
>    }
> }
> MyValidator.properties
> MyValidator=${label} is invalid
> MyValidator_nl.properties
> MyValidator=${label} is niet goed
> Igor also asked for package level resource bundles

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (WICKET-3879) Support FormValidator and package level resource bundles

Posted by "Martin Grigorov (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3879?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-3879.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 6.0.0
         Assignee: Martin Grigorov  (was: Igor Vaynberg)

In Wicket 6.0 IFormValidator can also have its own resource bundle as other IValidator's.


There is a comment in IFormValidator to make it implement IValidator and this will lead to a simplification in ValidatorStringResourceLoader but this will lead also to some API breaks which we try to avoid unless really needed.
                
> Support FormValidator and package level resource bundles
> --------------------------------------------------------
>
>                 Key: WICKET-3879
>                 URL: https://issues.apache.org/jira/browse/WICKET-3879
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Sylvain Vieujot
>            Assignee: Martin Grigorov
>             Fix For: 6.0.0
>
>
> Basically allow the following to work:
> public class MyValidator extends AbstractValidator {
>    protected void onValidate(IValidatable v) {
>        error(v);
>    }
> }
> MyValidator.properties
> MyValidator=${label} is invalid
> MyValidator_nl.properties
> MyValidator=${label} is niet goed
> Igor also asked for package level resource bundles

--
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