Laurie Harper wrote the following on 7/12/2005 8:25 PM:
Rick Reumann wrote:

(By the way I pass in an optional default format in my constructor as shown above, but my converters have a setFormatPattern(..) method that can change the format at any time)


Don't you end up with thread safety issues calling setFormatPattern() though? I would want to call setFormat (or setLocale() or something) on a per-request basis to cater to the individual user.

I probably would:) I just haven't thought about it that far in advance since currently I don't have to deal with it. I'd be curious how others use BeanUtils in circumstances where the Date formats would differ.

My wimpy way out would be to simply do something to what Larry does (I think this is what he suggested)... put the ValueObject as a property in the form bean and have String properties in the form bean that set the different data types in the ValueObject. Then, I wouldn't even need to use BeanUtils. Actually I'm thinking about adopting that pattern anyway since it seems like less work. It's sort of annoying as it is to have to write custom converters to handle situations where a blank or null field comes across and ends up setting my numeric wrappers to 0 vs null.

So instead I'd have maybe some properties in my form like:

stringBirthDate;

public void setStringBirthDate( Sring bDate ) {
   //Convert string here to Date based on Locale!
   //this is unique per user so no problems
   valueObjec.setBirthDate( date );
}

public String getStringBirthDate() {
   //convert valueObject Date to proper String format
}

I'd probably create this fields for only the properties that aren't Strings in the ValueObject. Then you don't need to use BeanUtils at all.

--
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to