Susan,

Here's a response to a different thread with the same type of code block:

http://marc.theaimsgroup.com/?l=struts-user&m=103669042429912&w=2

I understand this type of approach is used in the example app, but I'd say it's 
anything but good practice. In general, if you have an action that's going to 
pre-populate a form, it's action mapping should include a name (or attribute) 
attribute for the appropriate form. Struts will take care of finding or 
creating the form, ensuring that it's stored in the proper scope, and passing 
it to the execute/perform method. All you need to do then is cast it to the 
appropriate type.

Quoting Susan Bradeen <[EMAIL PROTECTED]>:

> If I have this code, which appears to be good practice, in the beginning 
> of my pre-action's execute() method:
> 
>    if (form == null) {
>       form = new SomeForm();
>       if ("request".equals(mapping.getScope())) {
>          request.setAttribute(mapping.getAttribute(), form);
>       }
>       else {
>          request.getSession().setAttribute(mapping.getAttribute(), form);
>       }
>    }
>    SomeForm myForm = (SomeForm)form;
>    /* populate form values ...  */
> 
> Do I also need to use the following line at the end (after form 
> population), or is this basically accomplishing the same as the above? 
> 
>    request.setAttribute(mapping.getAttribute(), myForm);
> 
> 
> Thanks,
> Susan Bradeen
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@;jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@;dotech.com>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to