Craig R. McClanahan wrote:
On Wed, 22 Jan 2003, PILGRIM, Peter, FM wrote:


Date: Wed, 22 Jan 2003 13:44:03 -0000
From: "PILGRIM, Peter, FM" <[EMAIL PROTECTED]>
Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
To: "Struts Users Mailing List (E-mail)" <[EMAIL PROTECTED]>
Subject: Creating an Action inside an Action

In the current API 1.1 beta3 which has changed.

I have an Action `Preloader' but I what to create or get another a reference
to Action `Activate'. What is the best way to do this.

public class Preloader extends DispatchAction {
	public void execute( ... ) {

		ActionServlet servlet = getServlet();
		RequestProcessor processor = servlet.getRequestProcessor();

		Action activateAction = processor.createActionCreate();

	}
}

Unfortunately the `ActionServlet.getRequestProcessor' call is protected.
What I was to do is prepopulate the action form that is
associated with `Activate' action mapping ?

		ActivateForm = magic_api.getActionForm( "/activate" );
		activateForm.setSymbol("alpha");

Then I can dispatch forward to the activate mapping.

This is sort of like action chaining but difference.

Any ideas on the new best practice?


The simplest thing to do is declare a form bean name in the <action>
element for Preloader -- then, Struts will precreate the bean for you and
pass it as the ActionForm parameter, ready for you to populate.  If you
use this technique, you'll probably also want to say validate="false" on
the preloader action, since the newly created form bean won't be able to
pass your validation checks.

For programmatic form bean creation, check out
RequestUtils.createActionForm().

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()'.

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

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
       __ _____ _____ _____
      / //__  // ___// ___/   +  Serverside Java
     / /___/ // /__ / /__     +  Struts
    / // ___// ___// ___/     +  Expresso Committer
 __/ // /__ / /__ / /__       +  Independent Contractor
/___//____//____//____/       +  Intrinsic Motivation
On Line Resume
   ||
   \\===>  `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''


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

Reply via email to