struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Barefoot" <>
Subject RE: How do you keep your session junk free?
Date Fri, 07 Mar 2003 19:00:54 GMT
Does this model include a means of managing the session objects (I would assume yes, but didn't
see anything to that effect)?  That is the real problem with wizards or wizard-like control

I had cooked up a similar idea, but haven't implemented it yet, because all the wizards already
had been built here using hidden fields to pass along values before I started.  I'll prolly
test it out if we have another wizard come along.

In the idea outlined below, I'm using the single "parameter" attribute, but you could use
the "set-property" attribs as well I these only exist in Struts 1.1?  Note that
the part at the bottom, "Extension", is something that I would definitely do...I just haven't
reformated these notes yet.

In a nutshell:

Notes for a 1-per-session wizard framework:
1.	Use a single "wizard bag" in session, just an object that contains a hashtable plus identifying
logical name for the wizard for which we are storing objects.
2.	Use the "parameter" attribute in action mapping to give logical name of wizard that this
action is a part of, if it is a wizard action.  Action classes that are used both in and out
of wizards should have multiple mappings-a mapping with a wizard parameter should be used
only inside a wizard flow.
3.	In abstract action superclass, test to see if actionmapping's parameter has a value. 
4.	If parameter has no value, remove the wizard bag from the session if it exists, as we are
no longer in a wizard.
5.	If parameter has a value:  If no wizard bag exists in session, create one with the parameter's
value as the logical name.   If the wizard bag does exist in the session, see if it's logical
name matches the parameter value-if it doesn't, remove the wizard bag and create a new one
with the current parameter value, as we have jumped to a new wizard.
6.	Our abstract superclass will have protected methods to access the wizard bag, for use by
wizard subclasses:  
storeWizardObject(String key, Object o);
getWizardObject(String key);
removeWizardObject(String key);

Use a naming scheme for the parameter values in our wizard actionmappings:  wizardName_step#.
 For example:  createEmployee_1, createEmployee_2, etc.  We would use the same rules as above,
except we would always create a new wizard bag in step one of the wizard (and drop the current
one even if it already exists).  We would also verify that the wizard bag with our current
wizard's logical name already exists in subsequent steps, and if it doesn't, forward to an
exception page (because this means we either lost the wizard bag in the middle of the process
due to another client browser's request (in the same session), or we jumped into the middle
of the wizard somehow - see #2 above).  Having the step number may be useful for other purposes
as well.


> -----Original Message-----
> From: Sloan Seaman []
> Sent: Friday, March 07, 2003 8:33 AM
> To: Struts Users Mailing List
> Subject: Re: How do you keep your session junk free?
> I kinda have a class that does that if you want.
> I have an Action called ChainAction that can call N number of 
> actions in a
> row and passes the same form and request info through all the actions.
> The last action in the chain is then used to do a foward to whatever.
> This is how I control all application flow via the struts-config file.
> Example:
>   <action 
> path="/app/campaign/promotion/type/pantryLoading/introAddChain"
> className="com.symbol.mobilecommerce.analysis.struts.ChainActi
> onMapping"
>      type="com.symbol.mobilecommerce.analysis.struts.ChainAction"
>    name="pantryLoadingIntro"
>    >
>    <set-property property="ROLE" value="admin"/>
>    <set-property property="PROPERTY_NAME" value="action"/>
>    <set-property property="CHAIN" value="Do Delete :
> /app/campaign/promotion/type/pantryLoading/introSaveMessageAdd,
> /app/campaign/promotion/type/pantryLoading/deleteBitmapAdd,
> /app/campaign/promotion/type/pantryLoading/introAddPage"/>
>    <set-property property="CHAIN" value="Add Bitmap :
> /app/campaign/promotion/type/pantryLoading/introSaveMessageAdd,
> /app/campaign/promotion/type/pantryLoading/addBitmapAdd,
> /app/campaign/promotion/type/pantryLoading/introEditPage"/>
>    <set-property property="CHAIN" value="Next:
> /app/campaign/promotion/type/pantryLoading/introSaveMessageAdd,
> /app/campaign/promotion/type/pantryLoading/messageTypeAddChain"/>
>    <forward name="PAGE_CHAIN_ERROR"
> path="/app/campaign/promotion/type/pantryLoading/"/>
>    <forward name="PAGE_ACCESS_DENIED"
> path="/app/campaign/promotion/"/>
>   </action>
> This action does security first (we have a custom system that 
> does role
> based security down to the action level).  If the user does 
> not have access
> it send them up the chain one step.  They continue up the 
> chain till they
> hit a point where they do have access.  This way we get them 
> to ass deep as
> they can go (get your mind out of the gutter). Anway..
> The chains work by defining a PROPERTY_NAME that relates to 
> an any element
> in a form.  In this case, submit buttons.  If the user 
> clicked "Do Delete"
> it sends them to introSaveMessageAdd and then to 
> deleteBitmap, and then to
> the introAddPage.
> This way my actions a very modular.
> You can also do a DECHAIN which will run through the actions 
> like normal but
> the last one is treated as a seperate request and gets a new form and
> request object (good for going from one form to another and 
> not having bean
> issues).
> It also does other things like you can defined a message to 
> put into the
> session at the end of the chain, etc...
> Anyway.. I can see if I can release the code if you want.
> ----- Original Message -----
> From: "julian green" <>
> To: "Struts Users Mailing List" <>
> Sent: Friday, March 07, 2003 11:04 AM
> Subject: Re: How do you keep your session junk free?
> > It would be neat if you could group a bunch of action definitions
> > together and have the form bean persist while the group 
> remianed active.
> >
> > Julian
> >
> > David Graham wrote:
> > >
> > >> Explain how some other approach handles it in any better 
> way? Use of
> > >> token to prevent duplicate submissions works for me. And 
> what do you
> > >> mean by a continuation-style programming?
> > >>
> > > The token approach is an easy solution.  One of the sites 
> listed was a
> > > Smalltalk web framework.  It's good to look at things in 
> different ways
> > > but you could probably count the number of Smalltalk web 
> applications on
> > > one hand :-).
> > >
> > > David
> > >
> > >
> > > _________________________________________________________________
> > > Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> > >
> > >
> > >
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > For additional commands, e-mail: 
> > >
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message