If you have a variable called action that keeps track
of what type of action you are performing (create,
update, delete), you could check for this in the
validate method and only validate on create or update.
 The Struts example webapp has an action field to keep
track of this.  I wouldn't do that personally.  I've
always done my validation from the Action so I could
use the same action for everything associated with a
form/table.  For example, delete doesn't need
validation or sending someone through the action to
the view for the first time (as you mentionded).  So I
don't think there is anything wrong with not using the
automatic validation.  I think it just depends on your
design preference.

David

--- "Emaho, Ghoot" <[EMAIL PROTECTED]> wrote:
> Some further details on my question:
> 
> I understand that you can have the request go
> straight to the JSP and
> avoid the first time validation.
> 
> This is acceptable in some circumstance, but in
> other circumstances you
> may wish to have your action do some work before
> presenting the page (a
> common requirement in more complex applications),
> and you may wish to
> avoid access to any JSP's directly.
> 
> How then (with this extra clarification) can you
> prevent the behaviour
> described in the original posting ?
> 
> Many thanks for any help
> 
> Ghoot
> 
> PS Please someone respond ! So i dont get too
> disillusioned :)
> 
> > -----Original Message-----
> > From: Emaho, Ghoot 
> > Sent: 31 July 2001 15:49
> > To: [EMAIL PROTECTED]
> > Subject: Automatic Form Validation
> > 
> > 
> > Quick question on Form validation, using the
> Automatic Validation
> > offerred by Struts.
> > 
> > If i have a form bean which performs some
> validation on the validate
> > method, and an action has it's definition of
> validate set to 
> > true, then
> > the Form Bean's validate method gets called before
> the 
> > action's perform
> > method. However, this then displays my error
> messages on the form page
> > the first time i go to the page !  Am I missing
> something ?
> > 
> > Now i can get round this with some checking in the
> validate method to
> > ignore it the first time round - as there will be
> no data yet. As i
> > understand, the bean is created if it isnt found.
> So if it's just been
> > created, and then the validate method is called of
> course 
> > there will be
> > nothing there ?
> > 
> > Any suggestions ? Or does someone want to point
> out the obvious ?!
> > 
> > In our Struts implementations to date, we have
> avoided using this
> > feature and done our validation from within the
> Action. But I am
> > investigating this feature and would like to know
> why this is 
> > so / what
> > i am doing wrong !
> > 
> > Many thanks
> > 
> > G
> > 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply via email to