You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jerry Jalenak <Je...@LABONE.com> on 2003/06/12 17:56:38 UTC

Cloning Form Beans

Hi All,

I have a form-bean defined in struts-config that is created in session scope
in a setup action, then used in another three actions (kinda of a wizard
thing).  In the second action I have to make an exact copy of the form bean
so I can do some comparisons between old and new values.  I initially
thought the the BeanUtils.cloneBean method would do the trick, but I'm
discovering that when my struts form-bean is updated, the cloned bean is
also being updated.  Leads me to believe that a copy is not really being
made, but a second reference is being created.  This form-bean is a fairly
complex set of nested beans; does anyone have a suggestion on the best way
to handle this?

TIA

Jerry Jalenak
Team Lead, Web Publishing
LabOne, Inc.
10101 Renner Blvd.
Lenexa, KS  66219
(913) 577-1496

jerry.jalenak@labone.com


This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at the following email address: securityincidentreporting@labone.com



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Cloning Form Beans

Posted by Paul Curren <pc...@cisco.com>.
Hi there,

I don't know the answer but reading the javadoc on cloneBean it states -
"Clone a bean based on the available getters and setters..."

So if the getter on your bean isn't making defensive copies (and neither 
is the setter) then i'd imagine your newly cloned bean will have 
properties that reference the same object as the original bean.

Paul C

Jerry Jalenak wrote:

>Hi All,
>
>I have a form-bean defined in struts-config that is created in session scope
>in a setup action, then used in another three actions (kinda of a wizard
>thing).  In the second action I have to make an exact copy of the form bean
>so I can do some comparisons between old and new values.  I initially
>thought the the BeanUtils.cloneBean method would do the trick, but I'm
>discovering that when my struts form-bean is updated, the cloned bean is
>also being updated.  Leads me to believe that a copy is not really being
>made, but a second reference is being created.  This form-bean is a fairly
>complex set of nested beans; does anyone have a suggestion on the best way
>to handle this?
>
>TIA
>
>Jerry Jalenak
>Team Lead, Web Publishing
>LabOne, Inc.
>10101 Renner Blvd.
>Lenexa, KS  66219
>(913) 577-1496
>
>jerry.jalenak@labone.com
>
>
>This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at the following email address: securityincidentreporting@labone.com
>
>
>
>---------------------------------------------------------------------
>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