You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frederic Dernbach <fr...@free.fr> on 2003/11/06 18:37:24 UTC
Best Practice : session vs. request attributes
I'm questioning my current design practice regarding Struts forms.
Until now, I tend to store all client data in the Struts form and I
avoid using other request attributes or session attributes.
But, this approach seems limited when I need to display a collection of
objects that are "very polymorphic". Let's say I need to display a
collection of instances of different classes A1, A2 and A3, that all
extend the same parent class A. A1, A2 and A3 have a very limited number
of common properties (described in class A).
If I store the collection of A's in the Struts form (as in indexed
property), I do not know to to code a <logic:iterate> tag in the JSP in
order to make sure that I won't loose data from request to request (what
preoperty attribute can I write for this tag ?) :
<logic:iterate name="myForm"
property="collection_of_As"
id="A"
type="WHAT SHOULD I WRITE FOR THIS ATTRIBUTE">
Therefore, in this case, I want to use a session attribute to store the
collection of As. Of course I won't loose client data from request to
request (action forward).
What is your point of view regarding this matter ?
Is it OK using session attributes (performance, memory, etc. ), even if
you make sure session attributes are removed when no more needed ?
Fred
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Best Practice : session vs. request attributes
Posted by Frederic Dernbach <fr...@free.fr>.
Vic,
Thanks for the input. I will use session-context forms. Things will be
easier in terms of design.
Fred
Le jeu 06/11/2003 à 18:48, Vic Cekvenich a écrit :
> >
> > Is it OK using session attributes (performance, memory, etc. ), even if
> > you make sure session attributes are removed when no more needed ?
> >
>
> I ALLWAYS use session for form bean and then clean up.
> I allways use request for read only beans (c:out, display tag, etc.)
>
> And there is a "non-standard" thing I do with formbeans, that is I
> implement Collection at BaseBean and have a DAO helper. Makes OO much
> cleaner.
>
> hth,
> .V
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Best Practice : session vs. request attributes
Posted by Vic Cekvenich <ce...@baseBeans.com>.
>
> Is it OK using session attributes (performance, memory, etc. ), even if
> you make sure session attributes are removed when no more needed ?
>
I ALLWAYS use session for form bean and then clean up.
I allways use request for read only beans (c:out, display tag, etc.)
And there is a "non-standard" thing I do with formbeans, that is I
implement Collection at BaseBean and have a DAO helper. Makes OO much
cleaner.
hth,
.V
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org