ActionErrors validate(ActionForm form,HttpServletRequest request) in perform(): ActionErrors errors = validate(addressForm,request); if(!errors.empty()) { saveErrors(request, errors); forward = "editAddress"; } else { // continue action.. }
following your method ive done something like the following.. I was thinking about the validation using Javascript but ive decided against it, since one can turn off javascript on the browser.. ----- Original Message ----- From: "Robert Parker" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 18, 2001 4:07 PM Subject: Re: where should validation happen? > Essentially correct. Thus javascript on the browser ensures that a date is a > date, a number a number etc. I like this approach as I can hook the > validation code into the onchange event of the form fields and hence the > user gets immediate error feedback. > > In my action classes, they assemble the request data back into generic > non-web specific beans. These beans then get passed to methods of the > business logic classes. Now my action classes are coded to trap two types of > errors - application errors and system errors. A system error would be > things like the database going down. An application error would be something > like a dealer going over his dealing limit etc. These errors get added to > the response with the saveerrors() method call... > > regards > > Rob > ----- Original Message ----- > From: "Francisco Hernandez" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, October 19, 2001 7:55 AM > Subject: Re: where should validation happen? > > > > so basically i take it as if you dont do anything in your form beans > > validate method? > > > > and you handle all errors in your actions perform method and saveErrors() > > and forward back to the input screen? > > > > > > > > ----- Original Message ----- > > From: "Robert Parker" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, October 17, 2001 9:35 PM > > Subject: Re: where should validation happen? > > > > > > > From my experience there are some subtle details when using the > validate() > > > method of the form bean... > > > > > > The validate method is called unless you set the validate attribute in > the > > > struts config to false. > > > > > > If an error is found by your validate method, struts seems to delegate > > back > > > to the input (jsp) as specified in the config, hence your action > handlers > > > perform method is not called. > > > > > > My preference is to perform basic field/type validation in the browser > > using > > > javascript, and business type validation I handle via beans called from > my > > > action handler class. > > > > > > Letting struts call the validate() method for me has given me problems - > > as > > > I often have my action handlers populate say collections of lookup > values > > > for selection lists etc. Hence if struts does not call my perform > method, > > my > > > selection lists will be empty. Note I discovered this after I had > designed > > > my action handlers this way... > > > > > > regards > > > > > > Rob > > > ----- Original Message ----- > > > From: "Francisco Hernandez" <[EMAIL PROTECTED]> > > > To: <[EMAIL PROTECTED]> > > > Sent: Thursday, October 18, 2001 10:06 AM > > > Subject: Re: where should validation happen? > > > > > > > > > > im sorry thats the SaveRegistrationAction not SaveSubscriptionAction > > > > ----- Original Message ----- > > > > From: "Francisco Hernandez" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Sent: Wednesday, October 17, 2001 5:01 PM > > > > Subject: where should validation happen? > > > > > > > > > > > > > in the struts example that comes with the stable release of struts > 1.0 > > > > there > > > > > is a SaveSubscribtionAction and it does some validation of the > > > > > SubscribtionForm but theres also validation in the validate() method > > of > > > > the > > > > > SubscribtionForm, so my question is, whats the difference between > > using > > > > the > > > > > forms validation() method and validating data in the Action? > > > > > > > > > > > > > > > > > > > > > > > > > >