I use something like the following in my struts-config.xml file: <action path="/signup" type="SignupAction" name="signupForm" scope="session" input="page1.jsp"> <forward name="page1" path="page1jsp"/> <forward name="page2" path="page2.jsp"/> <forward name="page3" path="page3.jsp"/> <forward name="page4" path="page4.jsp"/> <forward name="success" path="confirm.jsp"/> </action>
In page1.jsp I declare the following buttons: <html:hidden property="page" value="1"/> <html:submit> <bean:message key="button.next"/> </html:submit> Page2.jsp: <html:hidden property="page" value="2"/> <html:submit> <bean:message key="button.prev"/> </html:submit> <html:submit> <bean:message key="button.next"/> </html:submit> Page3.jsp <html:hidden property="page" value="3"/> <html:submit> <bean:message key="button.prev"/> </html:submit> <html:submit> <bean:message key="button.next"/> </html:submit> Page4.jsp <html:hidden property="page" value="4"/> <html:submit> <bean:message key="button.prev"/> </html:submit> <html:submit> <bean:message key="button.finish"/> </html:submit> In my SignupForm.java I define all fields for each page. Then I have a switch statement in the validate method to validate the data for each page: public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); switch (page) { case 1: // Validate fields on page 1 case 2: /// } return errors; } Finally in the SignupAction.java I check for which button was pressed and return the next or previous page: public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpSession session = request.getSession(); SignupForm signupform = (SignupForm) form; int page = signupform.getPage(); String label = request.getParameter("submit"); if (label != null) { if ("<< Prev".equals(label)) // Previous was pressed { return mapping.findForward("page"+(page-1)); } else if ("Next >>".equals(label)) // Next was pressed { return mapping.findForward("page"+(page+1)); // Finished was pressed } else if ("Finish".equals(label)) { // Do finish work, add data to database, whatever } ..... return(mapping.findForward("success")); I'm new to struts (about 2 weeks now). I tried to find examples but couldn't find any. So I hacked out this. Perhaps if someone has a better way we can all learn something new. I hope this helps. ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, April 24, 2001 9:51 AM Subject: wizard style example, anywhere? > Hello struts-users, > > I am very new to Struts (or JSP for that matter), and in need of > some examples that I can get my hands on. > > Specifically, an application that uses "wizard" style, multiple-page > input forms would be very nice. Couple of Struts documents I looked > mention that Struts works well with wizard style application, but I get > confused when it comes to writing struts-config.xml, JSPs that share > the same ActionForm or Action, etc.. I gotta see it working before I > start building mine. > > Good examples, anywhere, anyone? > > thanks, > > - kazumi >