[richfaces-issues] [JBoss JIRA] (RF-12104) BeanValidator: label not handled using MessageFactory

Markus Staab (JIRA) jira-events at lists.jboss.org
Wed Mar 28 03:51:47 EDT 2012


     [ https://issues.jboss.org/browse/RF-12104?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Markus Staab updated RF-12104:
------------------------------

    Description: 
The BeanValidator, in contrast to most JSF validators e.g. LongRangeValidator, does not use the MessageFactory to handle validation error message.

see LongRangeValidators' validate-method:

{code}
....
                        throw new ValidatorException(MessageFactory.getMessage
                             (context,
                                  NOT_IN_RANGE_MESSAGE_ID,
                                  stringValue(component, minimum, context),
                                  stringValue(component, maximum, context),
                                  MessageFactory.getLabel(context, component)));
...
{code}

Therefore error-message of a BeanValidator will neither prepand the String which is provided from the components' label-attribute nor the components' client id.

see BeanValidator's validate & extractMessages-method


{code}
....
	private Collection<String> extractMessages(Set<ConstraintViolation<Object>> violations) {
		Collection<String> messages = null;
		if (null != violations && violations.size() > 0) {
			messages = new ArrayList<String>(violations.size());
			for (ConstraintViolation<? extends Object> constraintViolation : violations) {
				messages.add(constraintViolation.getMessage());
			}

		}
		return messages;
	}

...
{code}

All error messages are taken 1:1 from the BeanValidator.


While e.g. the error-message of LongRangeValidtor looks like "Startdate: Value is greater than allowable maximum of ''{0}''." the error looks like "Value is greater than allowable maximum of ''{0}''.".
The reference to the component which violates the rule is not shown.

  was:
The BeanValidator, in contrast to most JSF validators e.g. LongRangeValidator, does not use the MessageFactory to handle validation error message.

see LongRangeValidators' validate-method:

{code}
....
                        throw new ValidatorException(MessageFactory.getMessage
                             (context,
                                  NOT_IN_RANGE_MESSAGE_ID,
                                  stringValue(component, minimum, context),
                                  stringValue(component, maximum, context),
                                  MessageFactory.getLabel(context, component)));
...
{code}

Therefore error-message of a BeanValidator will neither prepand the String which is provided from the components' label-attribute nor the components' client id.

see BeanValidator's validate & extractMessages-method


{code}
....
	private Collection<String> extractMessages(Set<ConstraintViolation<Object>> violations) {
		Collection<String> messages = null;
		if (null != violations && violations.size() > 0) {
			messages = new ArrayList<String>(violations.size());
			for (ConstraintViolation<? extends Object> constraintViolation : violations) {
				messages.add(constraintViolation.getMessage());
			}

		}
		return messages;
	}

...
{code}

All error messages are taken 1:1 from the BeanValidator.


While e.g. the error-message of LongRangeValidtor looks like "Startdate: Value is greater than allowable maximum of ''{0}''." the error looks like "Value is greater than allowable maximum of ''{0}''.".


    
> BeanValidator: label not handled using MessageFactory
> -----------------------------------------------------
>
>                 Key: RF-12104
>                 URL: https://issues.jboss.org/browse/RF-12104
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.3.3.Final
>         Environment: Liferay 5.2.4, Portlet 2.0, JSF 1.2
>            Reporter: Markus Staab
>
> The BeanValidator, in contrast to most JSF validators e.g. LongRangeValidator, does not use the MessageFactory to handle validation error message.
> see LongRangeValidators' validate-method:
> {code}
> ....
>                         throw new ValidatorException(MessageFactory.getMessage
>                              (context,
>                                   NOT_IN_RANGE_MESSAGE_ID,
>                                   stringValue(component, minimum, context),
>                                   stringValue(component, maximum, context),
>                                   MessageFactory.getLabel(context, component)));
> ...
> {code}
> Therefore error-message of a BeanValidator will neither prepand the String which is provided from the components' label-attribute nor the components' client id.
> see BeanValidator's validate & extractMessages-method
> {code}
> ....
> 	private Collection<String> extractMessages(Set<ConstraintViolation<Object>> violations) {
> 		Collection<String> messages = null;
> 		if (null != violations && violations.size() > 0) {
> 			messages = new ArrayList<String>(violations.size());
> 			for (ConstraintViolation<? extends Object> constraintViolation : violations) {
> 				messages.add(constraintViolation.getMessage());
> 			}
> 		}
> 		return messages;
> 	}
> ...
> {code}
> All error messages are taken 1:1 from the BeanValidator.
> While e.g. the error-message of LongRangeValidtor looks like "Startdate: Value is greater than allowable maximum of ''{0}''." the error looks like "Value is greater than allowable maximum of ''{0}''.".
> The reference to the component which violates the rule is not shown.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the richfaces-issues mailing list