Dom- This depends on the return of your ActionForm validate method If you can show us the code and I'll take a look at it tonite Thanks, Martin- ----- Original Message ----- From: "Dom Incollingo" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Sunday, April 03, 2005 4:25 PM Subject: Re: Form Submitted Twice
> Martin, > > Thanks very much for the info. > > I've tried to follow this pattern, both in the servlet-mapping in the > web.xml: > > > <servlet-mapping> > <servlet-name>pets</servlet-name> > <url-pattern>/action/*</url-pattern> > </servlet-mapping> > > and in the action element in the struts-config: > > <action > path="/petDetail" > type="com.dom.struts.pets.action.PetDetailAction" > scope="request" > name="petDetailForm" > validate="true" > input="/petDetail.jsp"> > <forward name="OwnerList" path="/action/getOwnerList"/> > <forward name="OwnerDetail" path="/action/ownerDetail"/> > <forward name="PetList" path="/action/getPetList"/> > <forward name="Success" path="/petDetail.jsp"/> > <forward name="Failure" path="/petDetail.jsp"/> > <forward name="Logoff" path="/action/logout"/> > </action> > > Evidently, something is not set up correctly, but it's not obvious to me > where the problem lies. I'm trying to step thru debug (using Eclipse > with Tomcat) to see if I can figure out what struts is having a problem > with. > > Thanks. > > Dom > > > Martin Gainty wrote: > > Dom > > Apparently the action tag was not setup properly to ensure validation before > > posting to RequestProcessor > > To quote James Goodwill and Rick Hightower > > For the purposes of simplicity, our sample legacy Web resource will be a > > servlet. Essentially, you want the servlet's doGet method to be called only > > if the ActionForm validates > > e.g. > > <servlet-mapping> > > <servlet-name>legacy</servlet-name> > > <url-pattern>/legacy/roar</url-pattern> > > </servlet-mapping> > > > > Thus, posts to /legacy/roar would cause this servlet's doPost method to be > > called. Now, to map this servlet as an action that acts as a form handler, > > you need to do this: > > > > <action > > path="/legacy" > > forward="/legacy/roar" > > input="/form/userForm.jsp" > > name="userForm" > > parameter="/legacy/roar" > > validate="true" > > scope="request" > > /> > > thus > > validate attribute is set to true in the action mapping for this servlet, so > > the execute method of the ForwardAction is called ONLY if the ActionForm > > (UserForm) validates (returns no ActionError objects). > > > > Makes sense? > > Martin- > > > > ----- Original Message ----- > > From: "Dom Incollingo" <[EMAIL PROTECTED]> > > To: "Struts User" <user@struts.apache.org> > > Sent: Saturday, April 02, 2005 6:34 PM > > Subject: Form Submitted Twice > > > > > > > >>Hello, > >> > >>I'm using Struts 1.2.4 (along with the validator framework), and I've > >>noticed that for my forms that do a Post, the action class is executed > >>twice. I put log statements in my Action class, in the validator > >>classes, in the Struts ActionServlet, and in the JSP to try to figure > >>out what is happening. The sequence of events is as follows: > >> > >>- User presses Update button on a JSP > >>- doPost method invoked (ActionServlet) > >>- Struts validation methods invoked > >>- execute method (Action class) entered > >>- execute method (Action class) returns forward action of Success > >>- processing returns to the same JSP > >>......................................................................... > >>- doGet method invoked (ActionServlet) > >>- Struts validation methods invoked > >>- execute method (Action class) entered > >>- processing returns to the same JSP > >>- web page is displayed on browser > >> > >>Everything prior to the doGet looks normal. I can't understand why the > >>JSP submits a Get request when it should display. The method specified > >>in the JSP's form (there is only one form in the JSP) is a Post, not a > >>Get. The JSP does not contain any form submission via JavaScript. > >> > >>I also notice that if I change the method in the JSP's form from Post to > >>Get, this problem goes away: the form is submitted only once! > >> > >>In a related problem, I have a JSP that does have a form with a method > >>of Get, but the user never clicks on a button to submit the form. > >>Instead, the user clicks on a link with a value like: > >> > > > > http://localhost:8080/pets/action/petDetail?userAction=Display&type=Pet&id=2 > > > > > >> I expect processing to go to the Action class associated with > >>'petDetail'. Processing does go there, but first a 'doGet' is processed > >>in the ActionServlet, even though a form was not submitted. > >> > >>Has anyone seen these problems or know what is happening here? Thanks > >>very much for your assistance. > >> > >>Dom > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > Linux is like a teepee: no Windows, no Gates, Apache inside. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]