Struts *does* support both the input and validation of dates in
international formats. See struts-validator.war in the Struts
distribution for an example.

I suspect you are defining a field on your ActionForm as type
java.util.Date and expecting Struts to correctly populate it. That is
not recommended and would only work with a date in yyyy-MM-dd format, as
you have found.

The ActionForm is *not* a business bean, it is merely a buffer for data
from your HTML form. ActionForms allow data to be validated before being
passed to your application and buffer the input values so they can be
redisplayed to the user (if a validation error occurs, for example).
Since form values are supplied via HTTP as Strings, it is recommended
that you only use Strings (and possibly booleans) in your ActionForms.

There are a couple of ways you can transfer form values to your business
beans:
1. Copy the properties to a business bean in your Action (possibly using
BeanUtils).
2. Add extra getters to your ActionForm that perform the type
conversions.

If you employ the second strategy you might have an ActionForm with a
StartDate property that returns a String. To get a Date, you could add a
second method, e.g. getStartDateAsDate() that performs the conversion
and returns a Date.

The two options are not mutually exclusive. Use whatever works for you.

For more info, please search the struts-user list archives. This subject
has cropped up before and you may find alternative explanations useful.

Steve


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: December 3, 2003 10:21 AM
> To: Struts Developers List
> Subject: Enhancement in forms
>
>
>
>
> Hello pros,
>
>      I am using Struts and found a bad problem: it doesn't accept
> internacionalized input for dates and numbers.
>      As experimented, dates are accepted only in the
> 'yyyy-MM-aa' pattern.
> I posted this bug at bugzilla for  Struts and commons-beanutils as I
> couldn't use it in the RequestProcessor to perform the
> localized populate.
>      I have a version of the RequestProcessor and
> common-beanutils here
> that works all right as I fixed them, posted the patches to
> bugzilla and I
> am waiting for something to happen!
>      Why doesn't Struts implement this feature? If it
> implements, how's
> it's used?
>
>      Will my patches be used for fixing theses bugs or I am
> doing it the
> wrong way?
>      I really need answers because it involves a very
> important project
> that will change the future of my company... one of our
> problems is that we
> have proprietary frameworks everywhere and we want to change
> to Struts if
> it fits our needs for the view layer.
>
>      Thank you guys,
>
> Stutz
>
>
>
>
>
> ---------------------------------------------------------------------
> 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