--- Jim Barrows <[EMAIL PROTECTED]> wrote:

> 
> 
> > -----Original Message-----
> > From: Woodchuck [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, August 12, 2004 7:24 AM
> > To: struts
> > Subject: lifetime of ActionForm objects
> > 
> > 
> > the following is my understanding, can someone please verify that i
> > have it correct?
> > 
> >   - when a form is first submitted, Struts will create an instance
> of
> > the ActionForm and then attempt to populate the submitted field
> data
> > via the JavaBean convention into the ActionForm object
> > 
> >   - this ActionForm object 'lives' in the session context
> > 
> >   - the next time the same form is submitted, Struts does not
> create a
> > new instance, but uses the one it created before
> 
> Actually, any form using that name... you can have several actions
> all using the same form name.

agreed.  but is my assumption correct that ActionForms are initially
created then re-used?  or are ActionForms only request scope, and
Struts creates a new instance each time a form is submitted (ie. prior
to Action being invoked)?


> 
> > 
> > the reason i'm asking is because i have a situation where it 
> > seems like
> > the html form is linked directly to an object that i keep in 
> > session...
> > i don't know how this is happening, but when i submit my form, the
> > object 'automatically' gets updated with the submitted form data...
> > however, this object is not even an ActionForm object... it's 
> > an object
> > that i manually copy ActionForm data to, but somehow it seems to
> have
> > been 'linked' to the html form and the next time the data fields
> are
> > updated before i even copy them there
> 
> How are you doing the copy?  I'm betting that the copy is binding the
> objects together in some way.  If all your doing is objectA=objectB
> (stringA = stringB) you aren't really copying in java, your sharing a
> reference to the same object.  If stringB is in the form, then every
> time stringB changes, everything referencing stringB will change,
> including stringA
> 

that's what i thought too, but i'm not doing objectA = objectB, i'm
doing objectB.setMyField(objectA.getMyField())...
i've also tried using BeanUtils.copyProperties(objectB, objectA)

in both cases, the mysterious binding is there and when i interrogate
my object in session (before my copy field data logic), the data is
already there somehow from the html form!  ..i'm at a loss still as to
how this 'bind' is possible..





                
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to