struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Benedict (JIRA)" <>
Subject [jira] Closed: (STR-2000) Automatic invalid format handling for form bean
Date Tue, 13 Nov 2007 08:22:37 GMT


Paul Benedict closed STR-2000.

    Resolution: Won't Fix
      Assignee:     (was: Struts Developers)

> Automatic invalid format handling for form bean
> -----------------------------------------------
>                 Key: STR-2000
>                 URL:
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.1 RC2
>         Environment: Operating System: All
> Platform: All
>            Reporter: Enzhong Fu
>            Priority: Minor
> Currently, Struts recommends all fields of ActionForm be of type String. If you 
> use other type (such as Date), and user inputs the value in an invalid format 
> so the value could not convert to the suitable type, BeanUtils would throw an 
> exception and it would propagate back to the user. Use only String type for 
> ActionForm fields can display to the user the original values they input, but 
> in Action class code is needed to transform from String type to type used in 
> business objects.
> Not all people like this. Today one more developer posted it as a bug. Ideally, 
> we hope to use more types in a form bean while still able to display the 
> original inputs to the user when a validation error occurs. I think the 
> following solution can achieve it,
> 0. Basic validation, "Valid Format" and "Required", should be handled before 
> populating form bean.
> 1. In RequestProcessor class, processPopulate() should mimic processValidate(). 
> It returns a boolean to indicate whether processPopulate is successful or not. 
> If not successful, it should forward to the input page like processValidate 
> does.
> 2. Instead of throwing exception, BeanUtils class should catch the exception 
> for populating error and continue. It returns a list of the fields that have 
> problem (normally invalid format). Error messages constructed based on these 
> fields will be stored in Globals.ERROR_KEY.
> 3. When there is populating error, a HashMap is created to hold the original 
> request parameters (all Strings, nested fields can have nested HashMaps). The 
> HashMap is stored at a global key ( in the request.
> 4. The html:form tag will get the stored HashMap and put it to 
> Constants.BEAN_KEY for field tags to use (when there is populating error).
> Thus, you can use other types in form bean (nest business objects in form bean, 
> for example) and Struts can still display the user's original input when in 
> error. I tried it on Struts1.1-rc2 and it worked. 
> An alternative solution is that in RequestProcessor, process() can catch the 
> exception and call processException(). It's up to the developer to provide 
> handler to deal with the invalid format. They can implement this proposal there.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message