You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ben <ne...@gmail.com> on 2004/12/07 12:17:53 UTC

Best approach to implement date dropdown

Hi

I am using Struts with Velocity as a replacement to JSP. I would like
to implement a date drop down list and love to hear your opinions on
the best way to implement it.

I like to have something like these on my ActionForms and use
ValidatorPlugin to validate the data:

[MM] [DD] [YYYY]

Or

>From [MM] [DD] [YYYY] to [MM] [DD] [YYYY]

I am planning to create two DynaValidatorForm: DateForm and
TimePeriodForm. Something like these:

DateForm {
Integer month;
Integer day;
Integer year;
}

TimePeriodForm {
DateForm start = new DateForm();
DateForm end = new DateForm();
}

So in my form, I can call them as timeperiod.start.month,
timeperiod.start.day and timeperiod.start.year, etc...

My concern is how to validate the data and make sure the start date
less than the end date.

I am looking forward to hear from you.

Thanks,
Ben

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


Re: Best approach to implement date dropdown

Posted by Bill Siggelkow <bi...@bellsouth.net>.
If your users are happy with the separate drop-downs for month, date, 
and year than this approach allows the greatest control. However, since 
the data is spread between multiple input fields, I think you will find 
that it is easier to implement validate() yourself instead of trying to 
use the Validator.

Certainly ensuring that the to date is greater than the from date is a 
custom validation.

You might want to look into using a Calendar control. This can give you 
the best of both worlds; controlled input but still convenient for the 
end-user. I have had good luck with 
http://www.mattkruse.com/javascript/calendarpopup/.

-Bill Siggelkow

Ben wrote:
> Hi
> 
> I am using Struts with Velocity as a replacement to JSP. I would like
> to implement a date drop down list and love to hear your opinions on
> the best way to implement it.
> 
> I like to have something like these on my ActionForms and use
> ValidatorPlugin to validate the data:
> 
> [MM] [DD] [YYYY]
> 
> Or
> 
> From [MM] [DD] [YYYY] to [MM] [DD] [YYYY]
> 
> I am planning to create two DynaValidatorForm: DateForm and
> TimePeriodForm. Something like these:
> 
> DateForm {
> Integer month;
> Integer day;
> Integer year;
> }
> 
> TimePeriodForm {
> DateForm start = new DateForm();
> DateForm end = new DateForm();
> }
> 
> So in my form, I can call them as timeperiod.start.month,
> timeperiod.start.day and timeperiod.start.year, etc...
> 
> My concern is how to validate the data and make sure the start date
> less than the end date.
> 
> I am looking forward to hear from you.
> 
> Thanks,
> Ben


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


Re: Best approach to implement date dropdown

Posted by Ben <ne...@gmail.com>.
Hi Carlos

I was meant to say ValidatorForm.

Cheers
Ben

On Tue, 7 Dec 2004 09:42:08 -0600, Carlos Cajina <ce...@hotmail.com> wrote:
> Good mornign Ben...
> 
> I've settled for the quick & easy solution: there are lots of JavaScript
> scripts that can handle date selection boxes :^) The thing is I don't know
> much about Velocity :^(
> 
> As for the validation, with the Validator Framework (VF) you can validate
> that the dates entered/selected by the user are valid dates (i.e. dates in a
> specific format [pattern]) You can also combine the VF with ValidatorForm's
> validate() method to check date ranges or any other complex date validation.
> 
> I'm not shure why you'd want to use a "date bean" in the form of a
> DynaValidatorForm, maybe you could comment more on your intended solution...
> 
> Regards,
> 
>     Carlos
> 
> 
> 
> ----- Original Message -----
> From: "Ben" <ne...@gmail.com>
> To: "Struts" <us...@struts.apache.org>
> Sent: Tuesday, December 07, 2004 5:17 AM
> Subject: Best approach to implement date dropdown
> 
> > Hi
> >
> > I am using Struts with Velocity as a replacement to JSP. I would like
> > to implement a date drop down list and love to hear your opinions on
> > the best way to implement it.
> >
> > I like to have something like these on my ActionForms and use
> > ValidatorPlugin to validate the data:
> >
> > [MM] [DD] [YYYY]
> >
> > Or
> >
> > From [MM] [DD] [YYYY] to [MM] [DD] [YYYY]
> >
> > I am planning to create two DynaValidatorForm: DateForm and
> > TimePeriodForm. Something like these:
> >
> > DateForm {
> > Integer month;
> > Integer day;
> > Integer year;
> > }
> >
> > TimePeriodForm {
> > DateForm start = new DateForm();
> > DateForm end = new DateForm();
> > }
> >
> > So in my form, I can call them as timeperiod.start.month,
> > timeperiod.start.day and timeperiod.start.year, etc...
> >
> > My concern is how to validate the data and make sure the start date
> > less than the end date.
> >
> > I am looking forward to hear from you.
> >
> > Thanks,
> > Ben
> >
> > ---------------------------------------------------------------------
> > 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
> 
>

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


Re: Best approach to implement date dropdown

Posted by Carlos Cajina <ce...@hotmail.com>.
Good mornign Ben...

I've settled for the quick & easy solution: there are lots of JavaScript 
scripts that can handle date selection boxes :^) The thing is I don't know 
much about Velocity :^(

As for the validation, with the Validator Framework (VF) you can validate 
that the dates entered/selected by the user are valid dates (i.e. dates in a 
specific format [pattern]) You can also combine the VF with ValidatorForm's 
validate() method to check date ranges or any other complex date validation.

I'm not shure why you'd want to use a "date bean" in the form of a 
DynaValidatorForm, maybe you could comment more on your intended solution...

Regards,

    Carlos

----- Original Message ----- 
From: "Ben" <ne...@gmail.com>
To: "Struts" <us...@struts.apache.org>
Sent: Tuesday, December 07, 2004 5:17 AM
Subject: Best approach to implement date dropdown


> Hi
>
> I am using Struts with Velocity as a replacement to JSP. I would like
> to implement a date drop down list and love to hear your opinions on
> the best way to implement it.
>
> I like to have something like these on my ActionForms and use
> ValidatorPlugin to validate the data:
>
> [MM] [DD] [YYYY]
>
> Or
>
> From [MM] [DD] [YYYY] to [MM] [DD] [YYYY]
>
> I am planning to create two DynaValidatorForm: DateForm and
> TimePeriodForm. Something like these:
>
> DateForm {
> Integer month;
> Integer day;
> Integer year;
> }
>
> TimePeriodForm {
> DateForm start = new DateForm();
> DateForm end = new DateForm();
> }
>
> So in my form, I can call them as timeperiod.start.month,
> timeperiod.start.day and timeperiod.start.year, etc...
>
> My concern is how to validate the data and make sure the start date
> less than the end date.
>
> I am looking forward to hear from you.
>
> Thanks,
> Ben
>
> ---------------------------------------------------------------------
> 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