You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by TKV Tyler VanGorder <TK...@landacorp.com> on 2001/05/11 02:07:26 UTC

Adding a new "workflow" scope type

I have seen this asked a couple of times on the strut users mailing list.

The problem this new "workflow" scope is meant to address is as follows:

When a browser client establishes a session with the servlet engine,
there is nothing stopping the user from opening up more than one browser
window during that session. This means that any data stored in the
session scope will be shared by both windows. A user can proceed through
an instance of the same workflow in each of their browser windows and there
is no way of distinguishing which data belongs to each instance. The
"request"
scope doesn't solve this problem if a workflow spans more than one browser
request.

Thus a new scope type: "workflow"

A workflow is started by a particular action mapping and a token
is generated to identify the workflow context. That ID is set on
an attribute of the request.

The workflow context is passed along by encoding the additional
workflow context ID into any URL that is embedded in the JSPs.

So, encoding a standard URL now goes through two layers....

- First we grab the workflow context ID from the request attributes.
- We encode the workflow context ID into our URL.
- Finally, we encode the new URL with the servlet's session ID.

You then modify the ActionServlet, so that when it gets a
request, it can parse out the workflow ID out of the encoded URL and
place it back into the request object.

Objects that are in "workflow" scope are stored in the user's session
using the workflow context ID as the key. The value of that entry is
another hashmap that allows arbitrary key/object mappings.

Finally, you identify a particular action as ending a workflow. The
action servlet parses our the workflow ID from the URL, does NOT put
that into the request object and removes all the data for that
workflow from the user's session.

Any comments on this?

Thanks

Tyler Van Gorder
tkv@landacorp.com
Landacorp.