Hi Puneet, Good to hear you have a solution. Item 3 in your list is exactly the situation I describe. Would you mind sharing the code with the user group ? Thanks James -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 28 July 2004 05:15 To: Struts Users Mailing List Subject: RE: Back navigation using application back buttons
I beleive this is really a desired feature, and I have a piece of code for doing all this. Which extends DispatchAction and RequestProcessor. We needed this for 1. BreadCrumbs 2. Wizard type of Screen 3. A situation when particular screen was being invoked from multiple places and there was a back button on the called screen. Puneet Agarwal Tata Consultancy Services Mailto: [EMAIL PROTECTED] Website: http://www.tcs.com [EMAIL PROTECTED] 07/28/2004 05:14 AM Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]> To "Struts Users Mailing List" <[EMAIL PROTECTED]> cc Subject RE: Back navigation using application back buttons Hi there, Another way to implement this is to *use* the struts config file. In my case I have a multi page form over four pages. All submissions are handled by the same Action class. However, the action is different for each form. For example: Page1: <form action="ProcessPage1"> <input type="hidden" name="page" value="1"> ... </form> Page2: <form action="ProcessPage2"> <input type="hidden" name="page" value="2"> ... </form> Both ProcessPage1 and ProcessPage2 are mapped to the same Action class. After processing the form, the Action will return a forward mapping of "back", "next", "print" or anything else that may be required depending on the button clicked in the page. Since there are individual mappings, I can use local forwards to control where to go; for example: <action path="/ProcessPage1" type="com.foo.ProcessFormAction" name ="myform" scope="session" input="page1"> <forward name="next" path="/jsp/page2.jsp" /> <forward name="cancel" path="/jsp/maybe_next_time.jsp" /> </action> <action path="/ProcessPage2" type="com.foo.ProcessFormAction" name ="myform" scope="session" input="page2"> <forward name="back" path="/jsp/page1.jsp" /> <forward name="next" path="/jsp/page3.jsp" /> <forward name="print" path="/jsp/page2.jsp" /> </action> Cheers, Martin "Meier, Niclas" <[EMAIL PROTECTED]> 28/07/2004 06:06 Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]> To "Struts Users Mailing List" <[EMAIL PROTECTED]> cc Subject RE: Back navigation using application back buttons Hello, You can try two hidden fields fort he 'currentPage' and 'lastPage'. When you submit any form with the 'next'-Button you can evalute the request determine the next page in your process. If you proceed with the back button, you can go back the the last page: Example 1 Page 1 (c:1, l:undef) -[fwd]-> Page 2 (c:2, l:1) -[back]-> Page 1 (c:1, l:2) Example 2 Page 1 (c:1, l:undef) -[fwd]-> Page 3 (c:3, l:1) -[fwd]-> Page 2 (c:2, l:3) -[back]-> Page 3 (c:3, l:2) You can implement this function into Abstract classes (From and Action) to handle the whole navigation. Or you create a dispatcher which all pages configured into. <action path="/foo/dispatcher" name="naviForm" type="com.foo.struts.DispatcherAction"> <forward name="1" path="/pages/page1.jsp"/> <forward name="2" path="/pages/page2.jsp"/> <forward name="3" path="/pages/page2.jsp"/> </action> A good idea maybe the seperation of request handling of the page form, which is related to the page and some stuff you need to prepare the view. I often use this pattern with great success. {Form on Page 1} -[submit]-> FormOneRequestHandlingAction -[forward]-> DispatcherAction -[forward]-> ViewPreparingActionPageTwo -[forward] -> Page2.jsp The first two actions can decide to return to page 1 and the third action will always forward to the jsp. Regards Niclas -----Original Message----- From: James Sheridan [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 27, 2004 4:51 PM To: '[EMAIL PROTECTED]' Subject: Back navigation using application back buttons Hi, I am trying to implement a simple Back mechanism which uses Back buttons in the page (encouraging users to use this rather than browser Back which is not a good idea). Lets call the pages Page1 and Page2. A Page 1 action brings user to Page 2. Page 2 has a Back button. The basic mechanism is trivial, ie. an action handler for Page 2 Back which forwards to Page1. However the problem is I want to be able to go Back to pages other than Page1 since the user can also get to Page 2 via Page3. ie. I want to be able to do Page1->Page2->(back)->Page1 Page1->Page3->Page2->(back)->Page3 Is there some way to control the forwarding for the Page2 Back handling and know which page to go back to ? The 'static' mappings I would set up in struts-config.xml appear to only allow me to configure navigation back to one specific page. I was considering implementing a 'page stack' object and passing it as a session attribute but I would have hoped that the Struts framework would make this possible in some easy way. I suppose some of the wizard ideas might help but a wizard is essentially different from what I cam trying to achieve in the sense that Back in a wizard always go back to a specific page. Any help would be greatly appreciated. -- James ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. ********************************************************************** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ForwardSourceID:NT00003756 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. **********************************************************************