Re: Forwarding to the previous page
On Wed, September 7, 2005 12:44 pm, Michael Jouravlev said: > Consider "standard" for Struts pre/post actions. You have showForm.do > -> JSP -> submitForm.do -> smthElse.do. > > The preceding action for smthElse.do is submitForm.do, so calling it > does not make sense, since it would try to submit a non-existent form. > By the way, your advice would work great with Struts Dialogs, where > each dialog, that is, a web resource, is controlled by one action > only. Yep, your right, fair point. Maybe the answer, since my other reply was talking about doing it from a base Action, is to only extend from that base Action those Actions that should be "return to-able" ;) In other words, have your showForm.do extend BaseAction, and smthElse.do extend BaseAction, but NOT submitForm.do. That way you only ever store Actions that can legitimately be returned to, and in this case if you wound up in smthElse.do and wanted to return to the previous page, meaning showForm.do, that's precisely what was last stored in session, NOT submitForm.do, as you point out would be incorrect. > Apparently, in "standard" approach with pre/post actions it makes > sense only to store pre-actions, that is, the rendering actions. In > the case above it would be "showForm.do". Exactly, hence my suggestion. :) > Michael. Frank - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
On 9/7/05, Tremal Naik <[EMAIL PROTECTED]> wrote: > 2005/9/7, Michael Jouravlev <[EMAIL PROTECTED]>: > > Apparently, in "standard" approach with pre/post actions it makes > > sense only to store pre-actions, that is, the rendering actions. In > > the case above it would be "showForm.do". > > well, I didn't really want to store the previous action path > (showForm.do), but instead the ActionForward path which correspond to > the one returned by the previous action. You mean, you want to jump directly to JSP instead of action class that shows the JSP? This is usually a bad idea. It is better to use actions in front of JSPs, it this case as well. But if you know what you are doing... > So I'd have the nice effect > of don't calling the previous action (it may be a vaste of resource), > just forwarding the actual to the forward path of the previous. I can > imagine I must be careful that all the object needed by the previous > are still 'alive'. Exactly. If you objects have request scope you would need to create them in the action. Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
2005/9/7, Michael Jouravlev <[EMAIL PROTECTED]>: > Apparently, in "standard" approach with pre/post actions it makes > sense only to store pre-actions, that is, the rendering actions. In > the case above it would be "showForm.do". well, I didn't really want to store the previous action path (showForm.do), but instead the ActionForward path which correspond to the one returned by the previous action. So I'd have the nice effect of don't calling the previous action (it may be a vaste of resource), just forwarding the actual to the forward path of the previous. I can imagine I must be careful that all the object needed by the previous are still 'alive'. I think the easiest solution will be defining a navigation object into the session, where I may store the return path of the last action thanks, -- TREMALNAIK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
On Wed, September 7, 2005 12:56 pm, Tremal Naik said: > I was thinking of a navigation bean to store in the user session, but > is that 'modifying ANY action' that I was trying to get rid of. Yep, I agree... but that's where a base Action comes in to play :) I suppose it's still a change to all your Actions, but then it's just adding an extends clause. Frank - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
2005/9/7, Frank W. Zammetti <[EMAIL PROTECTED]>: > I don't think there's anything inherently in Struts to do that, however, > it shouldn't be too hard to do on your own... how about this right before > you return your ActionForward from ANY Action: > > session.setAttribute("previousPage", mapping.getPath()); > I was thinking of a navigation bean to store in the user session, but is that 'modifying ANY action' that I was trying to get rid of. thanks -- TREMALNAIK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
Consider "standard" for Struts pre/post actions. You have showForm.do -> JSP -> submitForm.do -> smthElse.do. The preceding action for smthElse.do is submitForm.do, so calling it does not make sense, since it would try to submit a non-existent form. By the way, your advice would work great with Struts Dialogs, where each dialog, that is, a web resource, is controlled by one action only. Apparently, in "standard" approach with pre/post actions it makes sense only to store pre-actions, that is, the rendering actions. In the case above it would be "showForm.do". Michael. On 9/7/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: > I don't think there's anything inherently in Struts to do that, however, > it shouldn't be too hard to do on your own... how about this right before > you return your ActionForward from ANY Action: > > session.setAttribute("previousPage", mapping.getPath()); > > That way, assuming everything in your app does go through an Action, which > it generally should, than in any other Action you can get that attribute > and it represents the last Action that executed... you can then return an > appropriate ActionForward to get back to it. > > It would probably be a bit nicer to do this in a base Action, but that's > up to you, the theory is the same. > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > > On Wed, September 7, 2005 12:22 pm, Tremal Naik said: > > 2005/9/7, Duane Rosengartner <[EMAIL PROTECTED]>: > >> This works very well for me. > >> > >> Back > > > > aehm,probabily I didn't explain well my problem: I don't have to get > > back to the previous page from the actual. Look at this code: > > > > public class DisplayAboutAction extends Action > > { > > public ActionForward execute(ActionMapping actionMapping, > > ActionForm actionForm, > > HttpServletRequest httpServletRequest, HttpServletResponse > > httpServletResponse) > > { > > // do stuff. > > ActionForward af = new ActionForward(); > > af.setPath(previousPagePath); > > return af; > > } > > } > > > > I need to get a value for 'previousPagePath'. > > > > I'm trying something like : > > > > > > > paramProperty="servletPath"> > > > > but I'm using Tiles, so what I have as 'old_page' parameter is not the > > action 'previous.do' but '/jsplayout.jsp' instead > > > > thanks, > > > > TREMALNAIK > > > > - > > 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] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
The referer header is actually an unreliable value... I don't recall the details off the top of my head (perhaps someone else can fill in the blanks), but I do remember that using it for just about anything is on the dangerous side because you can't count on it being present and/or accurate. Just an FYI. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Wed, September 7, 2005 12:35 pm, [EMAIL PROTECTED] said: > You can always get from where the request is coming from by getting the > Referer from the Request. > String referer = request.getHeader("REFERER"); > > I'm not sure that this is want you want. You must beware that the referrer > can be blank when typing in the URL in the browser, plus the consequences > of the ActionForm.validate() and errors. > > HTH, > Glenn > > > > > Tremal Naik <[EMAIL PROTECTED]> > 07/09/2005 12:22 PM > Please respond to > "Struts Users Mailing List" > > > To > Struts Users Mailing List > cc > > Subject > Re: Forwarding to the previous page > > > > > > > 2005/9/7, Duane Rosengartner <[EMAIL PROTECTED]>: >> This works very well for me. >> >> Back > > aehm,probabily I didn't explain well my problem: I don't have to get > back to the previous page from the actual. Look at this code: > > public class DisplayAboutAction extends Action > { > public ActionForward execute(ActionMapping actionMapping, > ActionForm actionForm, > HttpServletRequest httpServletRequest, HttpServletResponse > httpServletResponse) > { > // do stuff. > ActionForward af = new ActionForward(); > af.setPath(previousPagePath); > return af; > } > } > > I need to get a value for 'previousPagePath'. > > I'm trying something like : > > > paramProperty="servletPath"> > > but I'm using Tiles, so what I have as 'old_page' parameter is not the > action 'previous.do' but '/jsplayout.jsp' instead > > thanks, > > TREMALNAIK > > - > 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]
Re: Forwarding to the previous page
I don't think there's anything inherently in Struts to do that, however, it shouldn't be too hard to do on your own... how about this right before you return your ActionForward from ANY Action: session.setAttribute("previousPage", mapping.getPath()); That way, assuming everything in your app does go through an Action, which it generally should, than in any other Action you can get that attribute and it represents the last Action that executed... you can then return an appropriate ActionForward to get back to it. It would probably be a bit nicer to do this in a base Action, but that's up to you, the theory is the same. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Wed, September 7, 2005 12:22 pm, Tremal Naik said: > 2005/9/7, Duane Rosengartner <[EMAIL PROTECTED]>: >> This works very well for me. >> >> Back > > aehm,probabily I didn't explain well my problem: I don't have to get > back to the previous page from the actual. Look at this code: > > public class DisplayAboutAction extends Action > { > public ActionForward execute(ActionMapping actionMapping, > ActionForm actionForm, > HttpServletRequest httpServletRequest, HttpServletResponse > httpServletResponse) > { > // do stuff. > ActionForward af = new ActionForward(); > af.setPath(previousPagePath); > return af; > } > } > > I need to get a value for 'previousPagePath'. > > I'm trying something like : > > > paramProperty="servletPath"> > > but I'm using Tiles, so what I have as 'old_page' parameter is not the > action 'previous.do' but '/jsplayout.jsp' instead > > thanks, > > TREMALNAIK > > - > 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]
Re: Forwarding to the previous page
You can always get from where the request is coming from by getting the Referer from the Request. String referer = request.getHeader("REFERER"); I'm not sure that this is want you want. You must beware that the referrer can be blank when typing in the URL in the browser, plus the consequences of the ActionForm.validate() and errors. HTH, Glenn Tremal Naik <[EMAIL PROTECTED]> 07/09/2005 12:22 PM Please respond to "Struts Users Mailing List" To Struts Users Mailing List cc Subject Re: Forwarding to the previous page 2005/9/7, Duane Rosengartner <[EMAIL PROTECTED]>: > This works very well for me. > > Back aehm,probabily I didn't explain well my problem: I don't have to get back to the previous page from the actual. Look at this code: public class DisplayAboutAction extends Action { public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { // do stuff. ActionForward af = new ActionForward(); af.setPath(previousPagePath); return af; } } I need to get a value for 'previousPagePath'. I'm trying something like : but I'm using Tiles, so what I have as 'old_page' parameter is not the action 'previous.do' but '/jsplayout.jsp' instead thanks, TREMALNAIK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Forwarding to the previous page
2005/9/7, Duane Rosengartner <[EMAIL PROTECTED]>: > This works very well for me. > > Back aehm,probabily I didn't explain well my problem: I don't have to get back to the previous page from the actual. Look at this code: public class DisplayAboutAction extends Action { public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { // do stuff. ActionForward af = new ActionForward(); af.setPath(previousPagePath); return af; } } I need to get a value for 'previousPagePath'. I'm trying something like : but I'm using Tiles, so what I have as 'old_page' parameter is not the action 'previous.do' but '/jsplayout.jsp' instead thanks, TREMALNAIK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Forwarding to the previous page
This works very well for me. Back -Original Message- From: Tremal Naik [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 07, 2005 7:24 AM To: Struts Users Mailing List Subject: Forwarding to the previous page Hi, I have a menu on my application, which is tiled in all the pages. I have an action of the menu which is common to all the page in which I am, so the execute() method of the action class associated to it must return a forward to the page which called it. I know how to map the forward of an action to a specific, struts-config hard-coded page. How can I deal with this kind of dynamic forwarding? Id est forwarding the action to the page which called it? Thanks -- TREMALNAIK - 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]