You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Nanduri, Amarnath" <Am...@Agilquest.com> on 2001/03/08 19:40:12 UTC

changing scope of the ActionForm objects at runtime


Hi all,

        Is it possible to change the scope of the ActionForm bean during
runtime ? 

For example i have a multi-page ActionForm Bean being used by different
Actions. After the user has filled in all the information in this
ActionForm, the user submits the information to an other Action Class. This
Action Class writes the information to a database, then has to show the user
the information entered by them (so that they can print it for their
records). After which, the ActionForm gets deleted (or) removed from
Sesison.

  To do this..i have given the ActionForm bean request scope (in all the
Actions which handle the user input). When the user submits info, and it
gets written to a database, i want to change the scope of this ActionForm to
"request" scope. On doing this the jsp page will show the information back
to the user, after which the ActionForm Bean gets deleted (since it has
request scope). 

  If i set the scope in the 'struts-config.xml' to 'session' for some
Actions and 'request' to the Action class which writes to database and
displays a page of all the user-entered information....will it work ?

   Any comments / suggestions will be greatly appreciated. Thanks.

cheers,
Amar..

Re: changing scope of the ActionForm objects at runtime

Posted by Anand Raman <an...@mymailbag.com>.
Hi Amar
I did something similar..

Whenever i needed a ActionForm for variable scope i always used the
session scope. Now whenever i needed the bean to persist only for the
request, i manully removed the attribute from the session scope.. Not a
very elegant solution, but still managed to solve my needs/..


Hope this helps
Anand 

No
On Thu, Mar 08, 2001 at 01:40:12PM -0500, Nanduri, Amarnath wrote:
>
>
>Hi all,
>
>        Is it possible to change the scope of the ActionForm bean during
>runtime ? 
>
>For example i have a multi-page ActionForm Bean being used by different
>Actions. After the user has filled in all the information in this
>ActionForm, the user submits the information to an other Action Class. This
>Action Class writes the information to a database, then has to show the user
>the information entered by them (so that they can print it for their
>records). After which, the ActionForm gets deleted (or) removed from
>Sesison.
>
>  To do this..i have given the ActionForm bean request scope (in all the
>Actions which handle the user input). When the user submits info, and it
>gets written to a database, i want to change the scope of this ActionForm to
>"request" scope. On doing this the jsp page will show the information back
>to the user, after which the ActionForm Bean gets deleted (since it has
>request scope). 
>
>  If i set the scope in the 'struts-config.xml' to 'session' for some
>Actions and 'request' to the Action class which writes to database and
>displays a page of all the user-entered information....will it work ?
>
>   Any comments / suggestions will be greatly appreciated. Thanks.
>
>cheers,
>Amar..