Howdy,

I'm working on a framework that allows a struts developer to reuse certain
wizard based pages where the wizard doesn't change, but the start and end
points do i.e. Basically a way to plug in a use case into other use cases.
The result of the wizard would be a bean (foreign key) that would be
assigned to a bean that requested the service of the wizard.

I would like to find out if the Workflow Context is for this situation. Is
there documentation or white paper that describes Workflow Context, and what
it is used for?

Thanks!

-ronel


-----Original Message-----
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 5:41 AM
To: [EMAIL PROTECTED]
Subject: Workflow Context


Something that has come up now and again is the idea of a "workflow"
context - more than a single request but less than a session. 

Towards that end, I've been experimenting with placing a Hashtable in
the session where I can store objects between requests, and remove them
when the mutli-request task is complete. I'm calling this a "Registry".

My current test case is leaving an input form to go off and look up some
foreign keys, and then have the keys filled in when you get back. 

To do this, I put an extra submit button next to the foreign keys. When
the action sees one of these come in, it puts the ActionForm in the
registry, and forwards to a search form for the key. 

String pickDonor = request.getParameter("pickDonor");
if (pickDonor!=null) {
    servlet.log("item.Access: Saving itemForm in Registry",2);
    registry.put(formName,thisForm);
    return mapping.findForward("pickDonor");
}

The data access Actions in the application register a form's key
property when appropriate:

// Remove or update donor key
if (task.equals("delete"))
  registry.remove(formKey);
else
  registry.setString(formKey,thisForm.getKey());

This is stateless and happens whenever the key is accessed.

Later, when they request an input form, the Action checks the registry: 

// -- Check registry; repopulate bean if form not finished
if (registry.containsKey(formName)) {
    servlet.log("item.Input: Restoring itemForm from Registry",2);
    Form itemForm = (Form) registry.remove(formName);
    try {
        BeanUtils.populate(thisForm,itemForm.getMap());
    }
    // :TODO: Generate "unexpected error" message
    catch (IllegalAccessException iae) {;}
    catch (InvocationTargetException ite) {;}
    thisForm.resetKeys(mapping,request);
}

You will note that the final trick is a "resetKeys()" method on the
ActionForm, which sets any foreign keys it is watching from the
registry, or to a default value is there is no registry key.

The registry is being setup when they login. If I keep this structure, I
could also keep the loginBean there so that my application just has the
one session object to manage. 

I'll be testing and refining this approach more today, and just wondered
if anyone else is working in this area.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/

Reply via email to