Re: Cloning Form Beans

2003-06-12 Thread Erik Price
Jerry Jalenak wrote: Erik, Thanks for the lesson - and I'll get out and get a copy of Josh's book. In the meantime I've also discovered that 'clone' basically does a shallow copy - i.e. if there is a nested construct of javabeans, clone will only copy the hightest level, and then place referenc

RE: Cloning Form Beans

2003-06-12 Thread Jerry Jalenak
---Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 2:12 PM To: Struts Users Mailing List Subject: Re: Cloning Form Beans Erik Price wrote: > But you're still not safe yet. > > What if somehow someone had held onto a reference to one o

Re: Cloning Form Beans

2003-06-12 Thread Erik Price
Erik Price wrote: But you're still not safe yet. What if somehow someone had held onto a reference to one of the Date objects passed into the constructor? Date myEvilStart = new Date(); Date end = new Date(); Period p = new Period(myEvilStart, end); // at this point is "p" immutable?

Re: Cloning Form Beans

2003-06-12 Thread Erik Price
Jerry Jalenak wrote: So, something like this? private String myString; public String getMyString() { String returnedString = this.myString; return (returnedString); } I'm not sure how this applies to my cloning issue Well, String it

RE: Cloning Form Beans

2003-06-12 Thread Derek Richardson
Don't you mean required for immutable classes that are ***composed by*** other objects which are mutable? > -Original Message- > From: Erik Price [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 12, 2003 1:39 PM > To: Struts Users Mailing List > Subject: Re

RE: Cloning Form Beans

2003-06-12 Thread Jerry Jalenak
, Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] -Original Message- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 12:39 PM To: Struts Users Mailing List Subject: Re: Cloning Form Beans Jerry Jalenak wrote:

Re: Cloning Form Beans

2003-06-12 Thread Erik Price
Jerry Jalenak wrote: Not sure what you mean by 'defensive copies' Is there something special I need to do in my bean so I end up with a 'true' duplicate, and not just a second reference? Defensive copies... described in Josh Bloch's "Effective Java". Getter methods return a copy of the pro

RE: Cloning Form Beans

2003-06-12 Thread Jerry Jalenak
96 [EMAIL PROTECTED] -Original Message- From: Paul Curren [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 12:19 PM To: Struts Users Mailing List Subject: Re: Cloning Form Beans Hi there, I don't know the answer but reading the javadoc on cloneBean it states - "Clone

Re: Cloning Form Beans

2003-06-12 Thread Paul Curren
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 tha

Cloning Form Beans

2003-06-12 Thread Jerry Jalenak
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 init