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().
> --
> Peter Pilgrim,
Craig
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>