Re-call the former action

Hi!
My problem is the following: the workflow should be
something like this:

Page1 ->
action1.execute(mapping1, form1, ...) {
  if(action2 is not performed)
  go to Page2
  }
  
  Page2 ->
  action2.execute(mapping2, form2, ...) {
    do something
    indicate in the session that it's been performed
    call action1.execute(mapping1, form1, ...) 
      // PROBLEM
    ...
    }
    
    
Now the problematic part is how to call
action1.execute with the mapping and form it was
called with originally.
What I came up so far is this: (pseudocode)

action1.execute(mapping1, form1) {
        if(!session.getAttr(ACTION2_PERFORMED)) {
                session.setAttr(MAPPING1, mapping1);
                session.setAttr(FORM1, form1);
                return new Forward(Page2);
        }
        ...
}

        
action2.execute(mapping2, form2) {
        ...
        mapping1 = session.getAttr(MAPPING1);
        form1 = session.getAttr(FORM1);
        session.setAttr(ACTION2_PERFORMED, true);
        return mapping1.getPath() + ".do";
}


This indeed calls in turn action1.execute(), but how
do I pass form1 to it?

As far as I know, when I forward to another action,
struts takes what is in the request and fills up the
form object assigned to the other action (action2 in
this case, so form2 is filled up). 
But what form2 needs to be filled up with is not in
this request anymore (because this is the request
posted from Page2), but is saved in session(FORM1)
instead. 

I can imagine a solution where I put all the
parameters from the saved form1 into the request just
to have struts fill it up again with these parameters
but it doesn't seem to be too nice a solution.

Another solution would be to have action2 extend
action1 but it should be more general so that it can
be called from a set of actions instead of only from
action1.

Or somehow the whole original request could be stored
and restored before going back to action1 (with the
modifications in the session intact), but I don't know
how.

Actually this pattern pops up from time to time and I
don't know of a general way to deal with it. (The
pattern: call an action, forward to another page, call
another action, call the original action with the
original parameters.)

Any ideas? Possibly a more elegant solution?

Thank you!
Agoston


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to