Your lazy (smart!) way #1 is correct. Let Struts instantiate your
ActionForms.

-Max

----- Original Message -----
From: "Fred Lamuette" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, January 22, 2003 4:17 PM
Subject: Newbie question


> For editing an article, i use this action, and of course i don't come from
a
> submitted form :
>
>    <action path="/article/edit"
>     type="com.xxx.ArticleAction"
>     name="articleForm"
>     scope="request"
>     validate="false">
>     <forward name="success" path="/pages/article.vm"/>
>     </action>
>
> And i use the folowing attributes
> (name="articleForm",scope="request",validate="false") only for not
> instanciating myself an articleForm in my ArticleAction, then i can
populate
> it and render it with article.vm.
> My question is : what is the best practice ?
> 1/ My lazzy way to get an instance of articleForm
> 2/ Put this code before populating the form bean ?
>   if (form == null) {
>     form = new ArticleForm();
>             if ("request".equals(mapping.getScope()))
>                 request.setAttribute(mapping.getAttribute(), form);
>             else
>                 session.setAttribute(mapping.getAttribute(), form);
> }
>
> Thank you
> Richard.
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>



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

Reply via email to