I tried posting this to struts-user group, trying one more time. > -----Original Message----- > From: Padma Ginnaram > Sent: Tuesday, October 15, 2002 4:43 PM > To: '[EMAIL PROTECTED]' > Subject: RE: Struts forms best practice > > > > -----Original Message----- > From: Padma Ginnaram > Sent: Tuesday, October 15, 2002 10:04 AM > To: '[EMAIL PROTECTED]'; 'David Winterfeldt' > Subject: RE: Struts forms best practice > > > I was going thru the new version of the validator framework used in > struts 1.1. The pluggable validators like Long,Date, etc seem to return > the parsed value. Am I correct in assuming that this parsed value was > intended to be used as a converted value?. Just want some feedback from > you to make sure I am using these framework properly. > > thanks, > Padma > > -----Original Message----- > From: Padma Ginnaram > Sent: Friday, October 11, 2002 2:07 PM > To: '[EMAIL PROTECTED]' > Subject: RE: Struts forms best practice > > Rules for validating also apply for converting the data, eg. > would be a specific date pattern used to validate a date field would also > be applied to converting the dates. Why not convert the data as part of > the validation? The same rules also apply for formatting the data which > can also be different based on the users locale. Don't these rules belong > in the view, so should I access them in the action? > > Here is what I am doing, appreciate any feedback. > > * My Form contains a value map pre-populated by an action class with > values that need to be formatted. > myForm.fromValue(myValue); > * I am using struts 1.0, extended the validator framework to support > validation/formatting rules to specify the formatters to be applied for > each field, extended the form tag to call these formatters on the form > beans value map. These formatted values are available for the body of the > tag. > * Validators(date, time, money, etc) parse these values and save the > converted value on the form beans value map. > * myForm.toValue() creates a value object using the values in the map, > this is called in the action class. > > thanks, > Padma > > > > > -----Original Message----- > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 11, 2002 1:00 PM > To: Struts Users Mailing List > Subject: Re: Struts forms best practice > > > > > On Fri, 11 Oct 2002, rainer juenger wrote: > > > Date: Fri, 11 Oct 2002 18:38:40 +0200 > > From: rainer juenger <[EMAIL PROTECTED]> > > Reply-To: Struts Users Mailing List > <[EMAIL PROTECTED]> > > To: [EMAIL PROTECTED] > > Subject: Struts forms best practice > > > > Hi, > > > > I was wondering what the best data type for Struts > ActionForm class is. > > According to the design I would say it should be the same > as the data type > > in the application. > > (e.g. float) But then the associated form already comes > with a "0" filed in > > the form. That's something I don't wont at all! > > As I found out, the only solution is to use String as data > type an convert > > it later. > > > > Is there a more elegant way? > > > > Form bean properties should generally be Strings, so that > you can > redisplay whatever the user actually typed. Do your > conversions in the > Action after validation is complete -- in 1.1b2 and later, > you can use > BeanUtils.copyProperties() to copy the form bean properties > into a > coresponding business object, complete with doing the > conversions as > needed. > > > Raine > > Craig > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

