FieldChecks.evaluateBean method is absolutaly wrong!!!
------------------------------------------------------
Key: STR-3051
URL: https://issues.apache.org/struts/browse/STR-3051
Project: Struts 1
Issue Type: Bug
Components: Core
Affects Versions: 1.3.8
Environment: Using with AndroMDA 3.2. Windows XP, Java 5.0
Reporter: Boda Béla
Priority: Critical
The method below is wrong, because if a bean has a java.lang.Double field the
validation is not working. The getValueAsString returns anything if the field
is set. But if the user types sharacters in a double field the bean has a NULL
value in that field, so this method returns null, that is wrong, because the
typed string is not visible any more.
Wrong method:
private static String evaluateBean(Object bean, Field field) {
String value;
if (isString(bean)) {
value = (String) bean;
} else {
value = ValidatorUtils.getValueAsString(bean, field.getProperty());
}
return value;
}
Good method to use:
private static String evaluateBean(Object bean, Field field,
HttpServletRequest request) {
String value;
if (isString(bean)) {
value = (String) bean;
} else {
value = request.getParameter(field.getKey());
}
return value;
}
PS: Can't send a patch, sorry!
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.