[ http://jira.andromda.org/browse/BPM-218?page=comments#action_11968 ]
     
Walter Itamar MourĂ£o commented on BPM-218:
------------------------------------------

>> indeed, it seems Struts is designed to only validate primitive 
>> numeric types

Not really. In fact Struts uses the org.apache.commons.beanutil.converters 
package to convert from one Class to another, String (from the http request) to 
Long (form attribute) in this case. The default behavior of the converters' 
classes is setting the value to null if the String cannot be converted. I 
changed this behavior creating converters classes with configurable error 
values and validators which check if the conversion error happened. 
It is important to set the new conversion behavior after the default Struts 
configuration. To do that I extended the 
org.apache.struts.config.ControllerConfig class and setted the struts-config 
(<controller className="app.Config" />) to load the new class.
I use this approach a lot, since I don't use primitives in forms.
I will attach some files to show the idea.

> Long validation is ignored
> --------------------------
>
>          Key: BPM-218
>          URL: http://jira.andromda.org/browse/BPM-218
>      Project: Bpm4Struts Cartridge
>         Type: Bug
>     Reporter: stephane le peutrec
>     Assignee: Wouter Zoons
>     Priority: Minor
>  Attachments: testLong.zip
>
> The validator "long" doesn't seem to work correctly. Indeed when a field of 
> type Long is filled with a string, no error occurs and the field of the form 
> is null in the controller. (cf. 
> http://galaxy.andromda.org/forum/viewtopic.php?t=435&highlight=validation)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.andromda.org/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf

Reply via email to