You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hudayioglu, Fehmi" <Fe...@Dresdner-Bank.com> on 2002/02/01 09:04:50 UTC

AW: Are Vectors in a FormAction set to null after a user has subm itted a form?

Hi default is session.

-----Ursprüngliche Nachricht-----
Von: Antony Stace [mailto:s45652001@yahoo.com]
Gesendet am: Friday, February 01, 2002 8:46 AM
An: Struts Users Mailing List
Betreff: Re: Are Vectors in a FormAction set to null after a user has
submitted a form?

Thanks for the reply Chuck.

The action I am calling is the first action after the form has been filled
in and the user submits the form.  All
the data should still be in the form.  I can access all the other variables
in this ActionForm which are of type String, so
I find it strange that the Vectors have become null.  
Any ideas? 


Cheers

Tony

On Fri, 01 Feb 2002 02:37:38 -0500
Chuck Cavaness <st...@japache.org> wrote:

> Just guessing, but the reason the Vectors are null is probably because the
action that is being called is configured as request scope and not session
in the Struts configuration file. Therefore, after the HTML page is drawn
(using the Vectors to populate the drop-down boxes), the ActionForm is
recycled because the request is complete. If you need data like this to
stick around and not have to get it again from your database or backend,
then you either going to have to make the action session scope, or hide the
data in the page. Take a look at the ActionMapping defined for the action
being called and see if it doesn't have something like scope="request".
Actually, I think the default is request, so if you don't have a line
scope="request" in the mapping, it will default to request scope.
> 
> You might try making this scope="session". Check out the JavaDoc on the
ActionMapping class for more information.
> 
> Chuck
> 
> p.s. Is anyone really using the Vector class anymore? Why aren't you using
List/ArrayList? Just curious.
> --
> Sent via jApache.org
> 
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>



_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: AW: Are Vectors in a FormAction set to null after a user has subm itted a form?

Posted by Chuck Cavaness <st...@japache.org>.
You are absolutely correct. That was my blurry-eyed mistake at 2am. Here's the code that shows that if nothing is defined, it's session scope:

if ("request".equals(mapping.getScope())) {
  request.setAttribute(mapping.getAttribute(), instance);
}else{
  HttpSession session = request.getSession();
  session.setAttribute(mapping.getAttribute(), instance);
}

In the "if" part of the statment, if mapping.getScope() call returns null, then ActionForm instance will always be set into the session in the else part of
the statment.

Thanks for the correction,
Chuck
--
Sent via jApache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>