You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marco Tedone <m_...@hotmail.com> on 2003/04/25 22:17:09 UTC

RE: Page Context Stack - a general solution to the problem ofreturning to your start page

We had the same problem in my project. We solved by implementing an XML
configuration file showing the relevant actions for visited page. In few
words it works like this:

1) When needed (in our case it means when an application exception is
thrown) we retrieve the last page visited by the user (like
/appname/login.jsp)
2) With this value, we match what we called a 'relevant action' to
forward the user to (generally defined in global forwards)

The XML configuration file looks like the following:

<?xml version="1.0" encoding="UTF-8"?>

<xmlop>

  <action>
    <lastPage>xml-op/Login.jsp</lastPage>
    <relevantAction>LOGIN</relevantAction>
  </action>

  <action>
    <lastPage>xml-op/Page.jsp</lastPage>
    <relevantAction>PAGE</relevantAction>
  </action>

</xmlop>  

Where the value of <relevantAction> represent a forward in struts. We
loaded the XML configuration info at startup asking help to a Struts
PlugIn and to commons-digester; now you can define a general Action
(let's say MyForwardAction) which retrieves from the request the last
page visited (xml-op/Login.jsp, where xml-op is the name of the
servlet-mapping) and then sets a mapping.findForward("String") value
with the value returned by <relevantAction>. This way, even if you're
writing another configuration file, the integrity between actions in
your application is kept, even if a blocking exception is thrown.

Hope it will help,

Marco

> -----Original Message-----
> From: Cody Sherr [mailto:csherr@covalent.net] 
> Sent: 24 April 2003 19:52
> To: Struts Users Mailing List
> Subject: Re: Page Context Stack - a general solution to the 
> problem ofreturning to your start page
> 
> 
> 
> I encountered exactly the same problem in a project, and was 
> interested in your original posting. I think that workflows 
> are a common requirement in web applications. 
> 
> We implemented something similar to what you described, a 
> stack of return paths that was stored in the session that 
> could be pushed and popped when calculating the forward to return.
> 
> A drawback is that the user can navigate anywhere in your 
> application, they're not necessarily going to "pop" when they 
> leave a workflow. 
> 
> There is a workflow extension to struts. I decided not to use 
> it because it would be a large migration problem for existing actions.
> 
> -Cody Sherr
> 
> On Wed, 2003-04-16 at 12:24, Jeff Smith wrote:
> > A while back I posted a question asking if anybody had a 
> > struts-friendly solution to returning to your starting 
> location after 
> > running a wizard or chained action sequence. While struts supports 
> > this if the starting location is fixed, it doesn't seem to for a 
> > sequence that could be launched from multiple locations. (I 
> call these 
> > "floating" action sequences.)
> > 
> > I never did get a response from anyone. (I think my question got 
> > buried under a flurry of activity on more popular threads. :-)
> > 
> > So I went ahead and implemented something that seems to work fairly 
> > well. In fact, I generalized the problem to that of creating a page 
> > context stack, with push and pop capabilities. Using this, 
> in theory, 
> > one could even implement nested wizard processes using multiple 
> > floating sequences - pushing page contexts on the way in 
> and popping 
> > them on the way out. And the best part is that you still use 
> > struts-config.xml to specify the chains.
> > 
> > The problem is, I still don't know if I've re-invented a 
> wheel here. 
> > Would this be useful to anybody else?
> > 
> > Jefficus
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > 
> > 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org