Jacob,

From the Javadoc for PropertyUtils:

"Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter and setter methods might have been customized via |BeanInfo| classes). No conversions are performed on the actual property values -- it is assumed that the values retrieved from the origin bean are assignment-compatible with the types expected by the destination bean."

Although this method is very useful, it won't help my conversion issue.

Hookom, Jacob wrote:

PropertyUtils is part of the commons-beanutils lib, included in the Struts
release.

It will require some testing, but you can do stuff like:

OrderVO order = new OrderVO();
PropertyUtils.copyProperties(actionForm, order);

Do some JUnit tests locally to make sure it does the conversions properly,
but it's the easiest route if it works in your case.

-jacob

-----Original Message-----
From: Aaron Longwell [mailto:[EMAIL PROTECTED]
Sent: Monday, June 23, 2003 11:12 AM
To: Struts Users Mailing List
Subject: Re: Where to do TextConversion?


I'm not really considering sending the action form to the db tier.


I am using Strings for all properties in the ActionForm.... I'm considering adding getter methods to the ActionForm to clean up the code in my Action.

PropertyUtils is a Struts class, right?
Will it do currency text->float conversion of properties?

Thanks,
Aaron

So I can do:

BusinessObject.setPrice(form.getPrice())

Hookom, Jacob wrote:



Your ActionForms should never be passed to your DB layer... ActionForms
should have strict String attributes and in your Action, take care of
mapping your Business Beans to your ActionForms and visa versa-- two
similar, but separate objects.  PropertyUtils works nicely.

Jacob

-----Original Message-----
From: Aaron Longwell [mailto:[EMAIL PROTECTED]
Sent: Monday, June 23, 2003 11:00 AM
To: Struts-User
Subject: Where to do TextConversion?


Struts Users,


I'm adding some currency fields to an ActionForm in struts. The data is stored as float in the database. I'm wondering where to do conversion between a "$6.70" that's displayed to the user on the form, and the 6.7 that's stored in the database. Should I use the java.util classes in the Action? Or should I add a:

setPrice(java.lang.Float)
getPrice java.lang.Float()

to the ActionForm... and handle conversion within the ActionForm methods?

I may be suffering from a case of the Mondays... but I can't seem to think which would be better or more appropriate. I am nearly finished with this, my first Struts project.

Thanks,
Aaron


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

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










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

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








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



Reply via email to