struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Closed: (STR-3051) FieldChecks.evaluateBean method is absolutly wrong!!!
Date Tue, 12 Jun 2007 17:03:31 GMT

     [ https://issues.apache.org/struts/browse/STR-3051?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Henri Yandell closed STR-3051.
------------------------------

    Resolution: Won't Fix

+1

> FieldChecks.evaluateBean method is absolutly 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.


Mime
View raw message