> <action path="/setupMultipleForms"
>         type="foo.bar.SetUpFormsAction"
>         name="form1"
>         scope="request"
>         validate="false"
>         >
>         <forward
>                 name="continue"
>                 path="/severalFormsOnAPage.jsp"/>
> </action>
> 
> So now in the SetUpFormsAction you can easily put Form1 into scope by:
>  
> Form1 form1 = (Form1)form;
> form1.setFoo("hello");
> request.setAttribute(mapping.getAttribute(), form1 );

Actually, unless you are going (back) to a page that contains a form with action of 
"setupMultipleForms" you can't use this strategy.

What you actually need to know is the name attribute of the action mapping 
corresponding to the page to which the user is being directed *next*.  However, this 
isn't the end of the world; you can programmatically figure the name of the form-bean 
etc as follows:

  ApplicationConfig appConfig = (ApplicationConfig)
    request.getAttribute(Globals.APPLICATION_KEY);
  ActionConfig actionConfig = appConfig.findActionConfig("/foo");
  String name = actionConfig.getName(); // Form bean name
  String attribute = actionConfig.getAttribute(); // Attribute to store under
  String scope = actionConfig.getScope(); // Scope to store in
  FormBeanConfig fbConfig = appConfig.findFormBeanConfig(name);

Now you've got all the metadata you need to dynamically instantiate the
appropriate form bean, and store it under the appropriate attribute in the
appropriate scope, without hard coding any of this stuff.

This is a snippet that Craig wrote up in response to an earlier post. 


Sri

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

Reply via email to