Take a look at BeanUtils.copyProperties.  By default, though, it doesn't
support conversion of dates, since it wouldn't know how you'd want your dates
formatted.  Check the archives of this list, there's been some discussion on
that.  Another archive you can check is that of the commons-user list.

If you're looking for further reduction in code, take a look at
http://www.rabago.net/struts/formdef which I'm working on.  It's alpha, but
an initial release is coming real soon (and I'm looking for folks to help me
develop/maintain it).

I believe the Struts dev team has plans to include functionality like this in
a future version of Struts.  For now, we either make do with BeanUtils, or do
the conversion ourselves, or through third party plugins like what I'm
working on.  If you feel strongly enough about it, you can rant some more on
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27321 though like I said,
the dev team has plans for supporting this functionality in a future version.
 How near or far into the future might be influenced by user requests.  :)


--- Joe Hertz <[EMAIL PROTECTED]> wrote:
> 
> I have a bean I persist with Hibernate. It's properties are:
> 
> 2 Floats
> 1 Integer (the key)
> 2 Dates
> 
> Now, relying on my handy dandy copies of Struts KickStart, Struts In
> Action, 
> and all of the Web, I'm apparently supposed to declare these methods in the
> 
> Form I am using as Strings since automatic type conversion can fubar them.
> 
> But Since the JSP I am using is getting these fields with html:text fields,
> I 
> apparently am supposed to have methods in form to do the type conversion
> for 
> me. Okay, that's light years better than putting this in the business
> layer, 
> but fine.
> 
> Is there an Automatic way I can get a DynaBean to do this for me? Maybe a
> Get
> (prop, type) and get(prop, type, value) for the types youd find in
> java.lang?
> 
> If not, there should be, because it limits what a DynaBean can do in a big 
> kinda way. Why have a type declaration in the DTD if youre only ever going
> to 
> want to use String and String[] ? :-)
> 
> I mean, it's not like I couldnt add such a set of methods to my 
> DynaValidatorActionForm subclass, but what I'd want is for the framework to
> 
> use them for me without me needing to know about it. (I dont ask for much,
> do 
> I???).
> 
> If not, I'd like to continue to use my Subclassed DynaValidatorActionForm 
> anyway, but I am wondering if it is going to be self-defeating to declare 
> custom getters and setters for properties that are declared in struts
> config? 
> Should I just use it as a non-dyna form?
> 
> Maybe I've been up too late (okay, I have) but it's the little things like 
> this that makes me feel like Struts is creating work for me rather than 
> saving me from it. 
> 
> 
> Tx for indulging my sleepy rant.
> -Joe
> 
> 

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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

Reply via email to