"Frye, Dave" wrote:
> Does any of this make sense?

Yes, but it might be helpful to nitpick some vocabulary just to avoid
later confusion. 

The best practice is for a JSP never to link to another JSP. All links
should be to Action Mappings, which in turn help decide which JSP (or
other view) to provide as response to the request. 

Also note that I said Action Mappings, not Actions. All the links
generated by the Struts Custom Tags refer to Action Mappings. One
property of an Action Mapping is the Action class, and the ActionServlet
uses this to decide which Action to call. It's important to keep this in
mind, since you can subclass the Action Mappings to provide for other
properties, including something that would help with flow control. 

(Another thing to note about Action Mappings is that they are
necessarily
static. The mappings database is initialized from the XML file, but
mappings can be inserted, removed, and modified at runtime.)

Lately, I have been thinking it would be helpful to setup a stack of
Action Mappings, and maybe an associated ActionForm, to provide things
like flow control. Of course, since there would be one of these for each
user, it would have to be a short stack. 

In the case you mentioned, A.jsp and B.jsp may have links to an A/C.do
and 
a B/C.do. The Action Mappings for each path could have different
input properties, one to A.JSP and the other to C.jsp. 

An instant kludge would to to have C.java pass the input to C.jsp as
part 
of the request, so that C.jsp could write that as a hidden input field 
to the "DONE" button's form. The DONE would then pass that back to
C.java, 
or a central dispatcher, who would forward to A.jsp or B.jsp, depending
on 
the "input" parameter.

Though, if I had a stack, C.java (an Action) could push the mapping 
instead, and the DONE button could go to a dispatcher who would 
pop the stack, and forward to the Action Mapping's input, or to a
default 
location if the stack were empty. The default could be specified in
"DONE"'s 
action mapping. 

If the ActionForm were also pushed, I could return to A.jsp or 
B.jsp with any interim input intact, since the dispatcher would also 
pop the ActionForm and pass it in the request, where the Struts HTML
tags 
will find it.

Then, if I could attach a "listener" to an ActionForm on the stack, it 
could be passed related properties accessed by C.java, and automatically 
place them on the ActionForms for A or B. (Imagining that C is a
database
lookup for a related property, like an account number.)

So, I'm on A.jsp, and click a "pick" button to lookup an account number. 
This calls C.java and C.jsp, and results in DONE button being pressed. 
Then, bingo, I'm back on A.jsp with the account number filled in. 

In between, C pushes the ActionMapping for A with it's ActionForm.
During this 
process the ActionForm registers an interest in the account property. 
C.jsp lists the accounts (perhaps with multiple pages and name
searches), 
with DONE buttons next to each one. 

Ultimately, DONE goes to a dispatcher which sniffs the incoming
ActionForm for 
any properties with listeners, and tells A's ActionForm about the 
account property on C. DONE then pops the stack, and forwards to 
A, with the updated ActionForm. 

Still thinking outload; comments appreciated.

-- 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