struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geeta Ramani" <geeta.ram...@cmpco.com>
Subject Re: Question regarding ActionForms.
Date Mon, 01 Dec 2003 16:07:19 GMT
Sepand:

google under "java pass by reference vs. pass by value" and look at the very
first result.  It contains a real nice discussion about this..

Geeta

EXCELSIS - Sepand Oboudiyat wrote:

> Hi,
>
> I am currently using Struts 1.0.2 and have notice something with regard to
> handling of ActionForms.
>
> Why is it, that in the "perform()" method of my Action I am able to modify
> the passed-in ActionForm and all modifications that I make to the
> ActionForm in my Action have effect on the ActionForm in the session,
> without the need to reset the modified form in the session. e.g.
>
> public ActionForward peform(ActionMapping mapping,
>                             ActionForm form,
>                             HttpServletRequest request,
>                             HttpServletResponse response,
>                             )throws IOException, ServletException
>
> {
>       MyForm myForm = (MyForm)form;
>
>       form.setMemberA("valA");
>       form.setMemberB("valB");
>
>       // why dont I have to do the following: session.setAttribute
> ("myFormName", myForm);
>
>       return "success";
>
> }
>
> I thought that since Java passes method arguments by value and not by
> reference, then I would have to reset my modifed copy back into the session
> for changes on the form to be visible in the form in the session ?
>
> Any insights on how this mechanism works would be greatly appreciated.
>
> Thanks,
>
> Sepand
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message