Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

S1.3.5: ActionForm with Date

Rick Schumeyer

2006-12-21

Replies:

I hope someone can show me a better way of doing this.

I have an input page in which the user enters a date. Of course, the
user really enters strings for month, day, and year.

My ActionForm has string fields dateOfBirthYear, dateOfBirthMonth, and
DateOfBirthDay.

It is my understanding that everything in a S1.3.5 ActionForm must be a
string...correct?

My "business bean" has a corresponding Date field called dateOfBirth.

I'm wondering if there is a better way to convert this data. I added a
field to the ActionForm called dateOfBirth (to match the field in the
business bean).
In the action, I call a method on the ActionForm called
"convertFromStrings" that combines the three strings into a Java Date
object and stores in into dateOfBirth.
I then use BeanUtils.copyProperties(businessBean, actionForm)

Of course, I need to do all this in reverse if I want to present an edit
form.

I think this rules out using a DynaActionForm ?

This must be a common issue, is there a better technique?

Finally, how many of these problems go away if I migrate to S2?




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.