You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Schumeyer <rs...@ieee.org> on 2006/12/21 19:23:32 UTC

S1.3.5: ActionForm with Date

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@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: S1.3.5: ActionForm with Date

Posted by Martin Gainty <mg...@hotmail.com>.
Hi Rick-
The 1.x alternative is to setup a validator (with a valid datetime pattern in validation.xml) as in
<field property="date" depends="date">
      <arg0 key="responseForm.date.displayname" />
      <var>
            <var-name>datePattern</var-name>
            <var-value>MM/dd/yyyy</var-value>
      </var>
</field>
ken sipe has a link here
http://64.233.161.104/search?q=cache:Z8HZgjeiSzoJ:bdn1.borland.com/borcon2005files/33218/33218_10091839_P.DOC+%22Struts+1.X%22+AND+%22Date%22+AND+%22Taglib%22&hl=en&gl=us&ct=clnk&cd=28

(or you can punt and upgrade to 2.x which would be the path of least resistance)

Thx,
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.

----- Original Message ----- 
From: "Rick Schumeyer" <rs...@ieee.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, December 21, 2006 8:13 PM
Subject: Re: S1.3.5: ActionForm with Date


>I just looked at it.  The head node of the docs says "struts 2" so my 
> impression is that datepicker only works for S2?
> 
> Martin Gainty wrote:
>> Hi Rick
>> Have you looked in DatePicker?
>> http://www.twdata.org/backups/WW/datepicker.html
>> Thx,
>> Martin --
>> --------------------------------------------------------------------------- 
>> This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
>> --------------------------------------------------------------------------- 
>> Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
>> ----- Original Message ----- 
>> From: "Rick Schumeyer" <rs...@ieee.org>
>> To: "Struts Users Mailing List" <us...@struts.apache.org>
>> Sent: Thursday, December 21, 2006 1:23 PM
>> Subject: S1.3.5: ActionForm with Date
>>
>>
>>   
>>> 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@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>     
>> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

Re: S1.3.5: ActionForm with Date

Posted by Rick Schumeyer <rs...@ieee.org>.
I just looked at it.  The head node of the docs says "struts 2" so my 
impression is that datepicker only works for S2?

Martin Gainty wrote:
> Hi Rick
> Have you looked in DatePicker?
> http://www.twdata.org/backups/WW/datepicker.html
> Thx,
> Martin --
> --------------------------------------------------------------------------- 
> This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
> --------------------------------------------------------------------------- 
> Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
> ----- Original Message ----- 
> From: "Rick Schumeyer" <rs...@ieee.org>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Thursday, December 21, 2006 1:23 PM
> Subject: S1.3.5: ActionForm with Date
>
>
>   
>> 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@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>     
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: S1.3.5: ActionForm with Date

Posted by Martin Gainty <mg...@hotmail.com>.
Hi Rick
Have you looked in DatePicker?
http://www.twdata.org/backups/WW/datepicker.html
Thx,
Martin --
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
--------------------------------------------------------------------------- 
Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
----- Original Message ----- 
From: "Rick Schumeyer" <rs...@ieee.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, December 21, 2006 1:23 PM
Subject: S1.3.5: ActionForm with Date


>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@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>