You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Rooms, Christoph" <CR...@SilverStream.com> on 2001/07/16 15:31:16 UTC

ActionForm Validation : Date restriction ?

Hi,

I have a form : "updateEvent", my ActionForm ("EventForm") only has got a
bean ("Event"). 

This Event bean has got one property : "EventDate" : a java.sql.date field.

My problem :

How can I check in my validate method if the user has really filled in a
date ? 

Or am I limited to work only with Strings on the level  of a form ?

Thanks !



Christoph Rooms
Technical Account Manager 
SilverStream Software 

tel    +32 2 474 47 17 
fax    +32 2 474 46 95
mobile +32 475 531 529


Learn more about fast and easy developing J2EE applications using the
SilverStream Workbench on Thursday July 26th (from 2pm - 5 pm) and Thursday
August 23th 

SilverStream eXtend Workbench simplifies and accelerates the creation,
assembly, consumption and deployment of J2EE and Web services-based
applications with wizards, visual designers, archive-based projects and
automatic deployment. 
SilverStream eXtend Workbench also includes integration with your favorite
IDE's, deploys to standard J2EE application servers and offers full J2EE,
XML, SOAP and WSDL support. 

Click here for the full agenda : www.silverstream.be
<http://www.silverstream.be/NewSilverSite/SilverStream/Pages/events_f.html> 
 <<Rooms, Christoph (CRooms@SilverStream.com).vcf>> 

Re: ActionForm Validation : Date restriction ?

Posted by David Winterfeldt <dw...@yahoo.com>.
The ActionForm is normally considered a step between
your pure data bean with class types like
java.sql.Date.  So most getters/setters on the
ActionForm will be a String.  Although for fields like
a checkbox or a select I use boolean or int
respectively.  If you don't use String, then when
there is an error validating or setting a field you
can't return the value to the user as they entered it
for them to fix.  So you would gather the information
from the form into the ActionForm and then when basic
validation like checking for required fields and a
phone number looks like a phone number you could copy
the values to a data bean with the correct class
types.  A couple of people have posted transformation
packages that will perform these conversion between
the two objects for you.  The links (among many
others) are posted here.

http://www.husted.com/about/struts/resources.htm

David

--- "Michael Q. Ma" <mi...@soprano.com.au> wrote:
> ActionForm Validation : Date restriction ?Every form
> bean can have a 'validate' method, you can do user
> input validation within this method and the
> ActionServlet will make sure to call it first then
> to the actual Action class you defined.
>   ----- Original Message ----- 
>   From: Rooms, Christoph 
>   To: 'struts-user@jakarta.apache.org' 
>   Sent: Monday, July 16, 2001 11:31 PM
>   Subject: ActionForm Validation : Date restriction
> ?
> 
> 
>   Hi, 
> 
>   I have a form : "updateEvent", my ActionForm
> ("EventForm") only has got a bean ("Event"). 
> 
>   This Event bean has got one property : "EventDate"
> : a java.sql.date field. 
> 
>   My problem : 
> 
>   How can I check in my validate method if the user
> has really filled in a date ? 
> 
>   Or am I limited to work only with Strings on the
> level  of a form ? 
> 
>   Thanks ! 
> 
> 
> 
> 
>   Christoph Rooms 
>   Technical Account Manager 
>   SilverStream Software 
> 
>   tel    +32 2 474 47 17 
>   fax    +32 2 474 46 95 
>   mobile +32 475 531 529 
> 
> 
> 
>   Learn more about fast and easy developing J2EE
> applications using the SilverStream Workbench on
> Thursday July 26th (from 2pm - 5 pm) and Thursday
> August 23th 
> 
>   SilverStream eXtend Workbench simplifies and
> accelerates the creation, assembly, consumption and
> deployment of J2EE and Web services-based
> applications with wizards, visual designers,
> archive-based projects and automatic deployment. 
> 
>   SilverStream eXtend Workbench also includes
> integration with your favorite IDE's, deploys to
> standard J2EE application servers and offers full
> J2EE, XML, SOAP and WSDL support. 
> 
>   Click here for the full agenda :
> www.silverstream.be 
>   <<Rooms, Christoph (CRooms@SilverStream.com).vcf>>
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: ActionForm Validation : Date restriction ?

Posted by "Michael Q. Ma" <mi...@soprano.com.au>.
ActionForm Validation : Date restriction ?Every form bean can have a 'validate' method, you can do user input validation within this method and the ActionServlet will make sure to call it first then to the actual Action class you defined.
  ----- Original Message ----- 
  From: Rooms, Christoph 
  To: 'struts-user@jakarta.apache.org' 
  Sent: Monday, July 16, 2001 11:31 PM
  Subject: ActionForm Validation : Date restriction ?


  Hi, 

  I have a form : "updateEvent", my ActionForm ("EventForm") only has got a bean ("Event"). 

  This Event bean has got one property : "EventDate" : a java.sql.date field. 

  My problem : 

  How can I check in my validate method if the user has really filled in a date ? 

  Or am I limited to work only with Strings on the level  of a form ? 

  Thanks ! 




  Christoph Rooms 
  Technical Account Manager 
  SilverStream Software 

  tel    +32 2 474 47 17 
  fax    +32 2 474 46 95 
  mobile +32 475 531 529 



  Learn more about fast and easy developing J2EE applications using the SilverStream Workbench on Thursday July 26th (from 2pm - 5 pm) and Thursday August 23th 

  SilverStream eXtend Workbench simplifies and accelerates the creation, assembly, consumption and deployment of J2EE and Web services-based applications with wizards, visual designers, archive-based projects and automatic deployment. 

  SilverStream eXtend Workbench also includes integration with your favorite IDE's, deploys to standard J2EE application servers and offers full J2EE, XML, SOAP and WSDL support. 

  Click here for the full agenda : www.silverstream.be 
  <<Rooms, Christoph (CRooms@SilverStream.com).vcf>>