Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@jakarta.apache.org Received: (qmail 71050 invoked by uid 500); 1 Aug 2001 10:55:46 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: struts-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 71040 invoked from network); 1 Aug 2001 10:55:46 -0000 Received: from relay1.mail.ifb.net (194.105.167.4) by h31.sny.collab.net with SMTP; 1 Aug 2001 10:55:46 -0000 Received: from moe.petrotechnics.com (petrotech-gw.abz.ifb.net [194.105.165.49]) by relay1.mail.ifb.net (8.11.3/8.11.3) with ESMTP id f71Ath511525 for ; Wed, 1 Aug 2001 11:55:43 +0100 (BST) Subject: RE: Automatic Form Validation - A further question MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 1 Aug 2001 11:51:57 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0 Message-ID: X-MS-Has-Attach: Content-Class: urn:content-classes:message X-MS-TNEF-Correlator: Thread-Topic: Automatic Form Validation Thread-Index: AcEZ6RGxa7jBFMv8QE+I1L239JcwMAAjlLng From: "Emaho, Ghoot" To: X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Thanks again David. I have explored extending ActionForm to check for and ignore first time validation. However, it seems from my debug, that the form bean is created a new each time. Can someone else confirm this ? My further question is this: If I choose NOT to use automatic validation, and my request goes to the Action first [not the JSP], then what isthe best way to determine in the action that this is the 'first time' for this form bean i.e. it has been created only as a result of the ActionServlet, not because it's coming from the form on a JSP ? I know you can check the values of the form bean, but this seems a little messy. Any suggestions ? Any help is appreciated, as this is an important issue for us. Cheers Ghoot > -----Original Message----- > From: David Winterfeldt [mailto:dwinterfeldt@yahoo.com] > Sent: 31 July 2001 18:43 > To: struts-user@jakarta.apache.org > Subject: RE: Automatic Form Validation >=20 >=20 >=20 > --- "Emaho, Ghoot" wrote: > > Thanks for the reply David. > >=20 > > Yeah, 'action' checking is another way of > > determining wether or not to > > do the validation. > >=20 > > I guess I was wondering if it was possible to > > configure the Form to > > prevent first time checking ? Would anyone else find > > this useful ? > >=20 > > Given the recent discussions about preventing direct > > acces to JSP's, it > > seems that the Form validation is designed [in > > default operation] in > > such a way as to expect that you have gone directly > > to the JSP first. > > This is one thing I wouldnt really ever want to do, > > as I prefer all > > requests to go through an action - even if it is > > just to redirect to the > > JSP [call me a control freak! but there area lot of > > others that feel the > > same :) ] > I think it is good to go through the controller if you > really want to keep the view separate. >=20 > >=20 > > I wonder if the Auto Validation should accomodate > > the more common > > scenario [certainly in larger applications] where > > you do want to force > > requests thru actions and avoid direct JSP access, > > but avoid first time > > validation. I guess Action Form could be extended to > > provide this, but I > > was hoping it would already be there - as it seems > > quite obvious and > > important. I dont think we should be encouraging > > people to go directly > > to the JSP as part of the Struts framework [just my > > 2p] > You could always have one Action class that handles > all things that are auto-validatded and another for > things that shouldn't be validated. I'm not sure how > you could have the framework handle something that is > specific for your application unless there was a > parameter that could turn off the auto-validation for > the current request > (org.apache.struts.action.Action.VALIDATE=3Dfalse). >=20 > >=20 > > Picking up on what you mentioned David, about > > handling all 'actions' > > todo with a form in the one Action class. We have > > some sceanrios where > > this is just not practical. What about those > > scenarios ?! > You can of course have as many actions to go with a > form as you want. I just prefer keeping it to a > minimum. >=20 > >=20 > > Thanks anyway David. > >=20 > > Any other comments ? > >=20 > > G > >=20 > > > -----Original Message----- > > > From: David Winterfeldt > > [mailto:dwinterfeldt@yahoo.com] > > > Sent: 31 July 2001 16:46 > > > To: struts-user@jakarta.apache.org > > > Subject: RE: Automatic Form Validation > > >=20 > > >=20 > > > 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.=20 > > 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).=20 > > So I > > > don't think there is anything wrong with not using > > the > > > automatic validation. I think it just depends on > > your > > > design preference. > > >=20 > > > David > > >=20 > > > --- "Emaho, Ghoot" > > wrote: > > > > Some further details on my question: > > > >=20 > > > > I understand that you can have the request go > > > > straight to the JSP and > > > > avoid the first time validation. > > > >=20 > > > > 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. > > > >=20 > > > > How then (with this extra clarification) can you > > > > prevent the behaviour > > > > described in the original posting ? > > > >=20 > > > > Many thanks for any help > > > >=20 > > > > Ghoot > > > >=20 > > > > PS Please someone respond ! So i dont get too > > > > disillusioned :) > > > >=20 > > > > > -----Original Message----- > > > > > From: Emaho, Ghoot=20 > > > > > Sent: 31 July 2001 15:49 > > > > > To: struts-user@jakarta.apache.org > > > > > Subject: Automatic Form Validation > > > > >=20 > > > > >=20 > > > > > Quick question on Form validation, using the > > > > Automatic Validation > > > > > offerred by Struts. > > > > >=20 > > > > > 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=20 > > > > > true, then > > > > > the Form Bean's validate method gets called > > before > > > > the=20 > > > > > 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 ? > > > > >=20 > > > > > 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=20 > > > > > there will be > > > > > nothing there ? > > > > >=20 > > > > > Any suggestions ? Or does someone want to > > point > > > > out the obvious ?! > > > > >=20 > > > > > 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=20 > > > > > so / what > > > > > i am doing wrong ! > > > > >=20 > > > > > Many thanks > > > > >=20 > > > > > G > > > > >=20 > > >=20 > > >=20 > > > __________________________________________________ > > > Do You Yahoo!? > > > Make international calls for as low as $.04/minute > > with=20 > > > Yahoo! Messenger > > > http://phonecard.yahoo.com/ > > >=20 >=20 >=20 > __________________________________________________ > Do You Yahoo!? > Make international calls for as low as $.04/minute with=20 > Yahoo! Messenger > http://phonecard.yahoo.com/ >=20