On Thu, 23 Jan 2003, Peter A. Pilgrim wrote:

>
> Actually, Craig, what I am looking for is:
>
> (1) How to find all the action mappings registered for a Struts application?
>      I would like to programmatically find out from inside `Action.execute()'.

*If* you are a good boy :-) and route all your incoming requests through
the controller servlet (as opposed to linking directly to a JSP page),
then the controller servlet will have stored the ModuleConfig object for
the selected application module as a request attribute under the key
represented by Globals.APPLICATION_KEY
("org.apache.struts.action.MODULE").  From the ModuleConfig you can get
everything you want to know that came from struts-config.xml for that
module.

>
> (2) How to programmatically instantiate and then invoke an Action?
>      I guess this is really is Action chaining, isn't.
>      I would prefer to call it `transitioning' as in giving up the
>      responsibility to process a http request to secondary action.
>

Set up an ActionForward that has a request URL mapped to another Action,
and return it from the first Action.

Be aware that I'm *not* a believer in Action chaining -- too many people
get surprised by the interactions with form beans when you do this.
Instead, I advocate that the one-and-only Action that you submit to should
delegate to all the individual pieces of business logic it needs to (in
separate classes), and that you should reuse these business logic classes
as needed in multiple actions.

If we want a real "chain of responsibility" pattern (which is what action
chaining is really about), we should set that up as a first class notion.
That's one of the ideas I'm looking at for Struts 2.x.  In the mean time,
though, I consider action chaining to be a misuse of the current
architecture -- although other Struts committers may disagree.

> In another earlier note, I found a way to forward dispatch using request
> attributes and local action forwards. I did it this way in Struts 1.0.2
> seven or eight months ago.
>
> --
> Peter Pilgrim

Craig


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

Reply via email to