Jim,
what about subclassing the Struts Action and add a new method (that will be
available to all your new Actions) like
protected void removeFormBean(ActionMapping mapping,
HttpServletRequest request) {
// Do not create the session if it doesn't exist...
HttpSession session = request.getSession(false);
if (session != null) {
// In Struts, the ActionForm is stored with a key
// corresponding to the "attribute" field of the mapping
session.removeAttribute(mapping.getAttribute());
}
}
Every time you need to process a new request (i.e. "clean up the data in the
page"), you can first call removeFormBean(...). With no need to call an
extra action.
Does this make sense?
Andrej
PS. The next step would be defining a setFormBean(form, mapping, request)
that could help forcing a bean...
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 28, 2001 6:13 PM
To: Struts Users Mailing List
Subject: Removing session scope form bean on short-circuit
Hi,
I have a multi-page transaction that uses a session-scoped form bean. The
action class that carries out the final transaction cleans up the form bean
from the session. The catch is that on earlier pages there are links that
allow the user to short-circuit the business transaction (cancelling it
effectively) and take them to some other destination. Those links either
have actions that are unrelated or are simple global forwardings with no
associated action.
What happens is that when they short-circuit like this, the form bean is
never cleaned up, and if they start a new one of these multi-page
transactions subsequently within the same session it begins with state from
the previously short-circuited operation.
I could claim that this is a feature. ;-)
I could create a "cancel" action that cleans up the form bean and always
returns a "success" logical forwarding, and use that as the action for the
short-circuit links. These is the easiest solution I have come up with,
but I thought I would see what you folks have to say.
Jim
Jim Weaver
Software Developer - ThoughtWorks
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>