You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Néstor Boscán <ne...@tcs.com.ve> on 2006/01/18 02:27:55 UTC

Is there a way to use Dates and Numbers with Dynamic Action Forms using a pattern?

Hi
 
Is there a way to use Dates with Dynamic Action Forms using a pattern. We
would like to use all our DTOs with Dynamic Form Beans but we're having
problem with Date and Numbers were we need to apply patterns. Is there a way
to do this?



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


Re: Is there a way to use Dates and Numbers with Dynamic Action Forms using a pattern?

Posted by Emmanouil Batsis <Em...@eurodyn.com>.
Dave Newton wrote:

>Néstor Boscán wrote:
>  
>
>>Is there a way to use Dates with Dynamic Action Forms using a pattern. We
>>would like to use all our DTOs with Dynamic Form Beans but we're having
>>problem with Date and Numbers were we need to apply patterns. Is there a way
>>to do this?
>>  
>>    
>>
>I'm not sure which use of the word "pattern" you're using; I assume you
>mean formatting (like MM-DD-YYYY vs. DD/MM/YY etc.)?
>

Just use your pattern of choice and a SimpleDateFormat to convert 
strings from your FormBean to Date objects. To safely do that it would 
be a good idea to use the validator, it's default pattern is MM/dd/yyyy 
but you can configure that, check out the struts validator docos.

Manos

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


Re: Is there a way to use Dates and Numbers with Dynamic Action Forms using a pattern?

Posted by Dave Newton <ne...@pingsite.com>.
Néstor Boscán wrote:
> Yes I know I can use Strings but the idea is to reuse my java beans
> properties that are Date or Number and not have extra attributes for them.
>   
Generally speaking it's a Best Practice to use ActionForms _only_ as a
way to get String data from the client to the server, performing some
validation (more or less) automagically. I would recommend against using
Dates etc. in it, but there's no technical reason why you couldn't.
Doesn't seem like a very good idea to me.
> You said something about IIRC, how can I use this?
>   
Ah. That means "If I Remember Correctly".

Dave



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


RE: Is there a way to use Dates and Numbers with Dynamic Action Forms using a pattern?

Posted by Néstor Boscán <ne...@tcs.com.ve>.
Hi Dave

Thanks for the anster.

Yes I know I can use Strings but the idea is to reuse my java beans
properties that are Date or Number and not have extra attributes for them.
You said something about IIRC, how can I use this?

Regards,

Néstor 


-----Mensaje original-----
De: Dave Newton [mailto:newton@pingsite.com] 
Enviado el: Wednesday, January 18, 2006 8:32 AM
Para: Struts Users Mailing List
Asunto: Re: Is there a way to use Dates and Numbers with Dynamic Action
Forms using a pattern?

Néstor Boscán wrote:
> Is there a way to use Dates with Dynamic Action Forms using a pattern. 
> We would like to use all our DTOs with Dynamic Form Beans but we're 
> having problem with Date and Numbers were we need to apply patterns. 
> Is there a way to do this?
>   
I'm not sure which use of the word "pattern" you're using; I assume you mean
formatting (like MM-DD-YYYY vs. DD/MM/YY etc.)?

Try using Strings as the form-property types. Validate the patterns via a
regex (called "mask" in struts validator land).

IIRC formsets support I18N via the 'country' and 'language' attributes, but
I'm fuzzy on this one.

Dave



---------------------------------------------------------------------
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: Is there a way to use Dates and Numbers with Dynamic Action Forms using a pattern?

Posted by Dave Newton <ne...@pingsite.com>.
Néstor Boscán wrote:
> Is there a way to use Dates with Dynamic Action Forms using a pattern. We
> would like to use all our DTOs with Dynamic Form Beans but we're having
> problem with Date and Numbers were we need to apply patterns. Is there a way
> to do this?
>   
I'm not sure which use of the word "pattern" you're using; I assume you
mean formatting (like MM-DD-YYYY vs. DD/MM/YY etc.)?

Try using Strings as the form-property types. Validate the patterns via
a regex (called "mask" in struts validator land).

IIRC formsets support I18N via the 'country' and 'language' attributes,
but I'm fuzzy on this one.

Dave



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