I read your threads and I can say I fully agree. My only concern is that even if PropertyEditor is too heavy for using it solely for type conversion, we still need some kind of converter. And in my opinion that should not be the form bean's business. In my case, I have tens of properties scattered in various bean which have the same type (ie. NumberKey) and they all need to be converted the same way. I could encapsulate the conversion code in a helper class or base class and use it for all my getter/setters, but that still represents a lot of (unnecessary) house-keeping coding. Whereas, with PropertyEditor, I simply had to register the editor once, and MAGIC! everything communicates perfectly. Don't you think there should be a cleaner way of achieving type conversion within Struts?
-- Mathieu -----Original Message----- From: Paul Speed [mailto:[EMAIL PROTECTED]] Sent: February 21, 2002 12:12 AM To: Struts Developers List Subject: Re: PropertyUtils with added PropertyEditor support Ok, Martin's initiative has made me dig up the link to my original PropertyEditor rant. :) http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02111.html It's also in the search results on the message he links to, but it's on the second or third page. That's the thread that I think Martin is referring to. -Paul Speed Martin Cooper wrote: > > The Struts PropertyUtils class is deprecated because it was moved to the > Commons project: > > http://jakarta.apache.org/commons/beanutils.html > > Regarding PropertyEditors, you can read my take on them, and the thread on > which my take is based, starting here: > > http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg03680.html > > -- > Martin Cooper > > ----- Original Message ----- > From: <[EMAIL PROTECTED]> > To: "'Struts Developers List'" <[EMAIL PROTECTED]> > Sent: Wednesday, February 20, 2002 5:31 AM > Subject: PropertyUtils with added PropertyEditor support > > > Hello. > > > > > > [In short] > > > > The (deprecated) PropertyUtils class doesn't seem to support > PropertyEditors > > at all. I had to modify the class to fit my purposes, by adding this > > support. For example, when trying to set a String into a property which > is > > not a String type, I check with the PropertyEditorManager for a > > corresponding editor, and try to use it for converting types. > > > > However, I'm a little worried because, first PropertyUtils is deprecated, > > second I had to modify and maintain my own version of the class (which > > overrides the one in the Struts jar). > > > > > > [My question] > > > > Should my modifications be included into cvs, or is there a cleaner way of > > achieving this kind of custom conversion? > > > > > > [More details] > > > > The reason for this need is that I'm using Torque and Torque's > > primary/foreign keys are in the form of NumberKey objects, which can be > > constructed from a String, or converted toString(). Obviously, at some > > point keys need to be as Strings (for the html form and parameters), and > at > > some other point as NumberKeys. I decided to make my Form Bean mimick the > > OM Bean by defining both of them with NumberKey properties, in order to > ease > > their implementation. This way the conversion must occur within Struts, > > when it tries to populate or read the Form Bean, which is performed with > the > > help of PropertyUtils. The PropertyEditor support did the trick for that. > > > > > > Any suggestions would be greatly appreciated... > > > > Best regards, > > > > -- Mathieu > > > > > > -- > > 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]> -- 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]>