struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Creating an Action inside an Action
Date Wed, 22 Jan 2003 20:20:54 GMT


On Wed, 22 Jan 2003, PILGRIM, Peter, FM wrote:

> Date: Wed, 22 Jan 2003 13:44:03 -0000
> From: "PILGRIM, Peter, FM" <Peter.PILGRIM@rbos.com>
> Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> To: "Struts Users Mailing List (E-mail)" <struts-user@jakarta.apache.org>
> 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().

> --
> Peter Pilgrim,

Craig



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message