[
https://issues.apache.org/jira/browse/MYFACES-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12889863#action_12889863
]
Jan-Kees van Andel edited comment on MYFACES-2827 at 7/19/10 9:52 AM:
----------------------------------------------------------------------
So, I guess the fix for this issue is to remove some code from BeanValidator.
The current code is:
final Class<?> valueBaseClass = base.getClass();
final String valueProperty = (String) reference.getProperty();
if (valueBaseClass == null || valueProperty == null)
{
return;
}
// Initialize Bean Validation.
final ValidatorFactory validatorFactory =
createValidatorFactory(context);
final javax.validation.Validator validator =
createValidator(validatorFactory);
final BeanDescriptor beanDescriptor =
validator.getConstraintsForClass(valueBaseClass);
if (!beanDescriptor.isBeanConstrained())
{
return;
}
But we can rewrite it to:
final Class<?> valueBaseClass = base.getClass();
if (valueBaseClass == null)
{
return;
}
// Initialize Bean Validation.
final ValidatorFactory validatorFactory =
createValidatorFactory(context);
final javax.validation.Validator validator =
createValidator(validatorFactory);
final BeanDescriptor beanDescriptor =
validator.getConstraintsForClass(valueBaseClass);
if (!beanDescriptor.isBeanConstrained())
{
return;
}
final String valueProperty = (String) reference.getProperty();
According to the spec, we should be able to remove the null-check on
valueProperty.
was (Author: jankeesvanandel):
So, I guess the fix for this issue is to add some extra code to
BeanValidator to check if the targeted object is a constrained object.
The current code is:
final Class<?> valueBaseClass = base.getClass();
final String valueProperty = (String) reference.getProperty();
if (valueBaseClass == null || valueProperty == null)
{
return;
}
// Initialize Bean Validation.
final ValidatorFactory validatorFactory =
createValidatorFactory(context);
final javax.validation.Validator validator =
createValidator(validatorFactory);
final BeanDescriptor beanDescriptor =
validator.getConstraintsForClass(valueBaseClass);
if (!beanDescriptor.isBeanConstrained())
{
return;
}
But we might be able to rewrite it to:
final Class<?> valueBaseClass = base.getClass();
if (valueBaseClass == null)
{
return;
}
// Initialize Bean Validation.
final ValidatorFactory validatorFactory =
createValidatorFactory(context);
final javax.validation.Validator validator =
createValidator(validatorFactory);
final BeanDescriptor beanDescriptor =
validator.getConstraintsForClass(valueBaseClass);
if (!beanDescriptor.isBeanConstrained())
{
return;
}
final String valueProperty = (String) reference.getProperty();
According to the spec, we should be able to remove the null-check on
valueProperty.
> CCE if component values are not of type String
> ----------------------------------------------
>
> Key: MYFACES-2827
> URL: https://issues.apache.org/jira/browse/MYFACES-2827
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.0.1
> Reporter: Mark Struberg
> Assignee: Jakob Korherr
>
> Somehow I did get a Long into my component. This leads to the following
> Exception:
> java.lang.ClassCastException: java.lang.Long cannot be cast to
> java.lang.String
> at javax.faces.validator.BeanValidator.validate(BeanValidator.java:145)
> at
> javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:173)
> at javax.faces.component.UIInput.validateValue(UIInput.java:425)
> at javax.faces.component.UIInput.validate(UIInput.java:537)
> at javax.faces.component.UIInput.processValidators(UIInput.java:240)
> at javax.faces.component.UIData.process(UIData.java:1043)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.