Ok - This is good info. Please file a bug report on
trac.reactorframework.com.
I'll look into it as soon as I can.
Doug
On 1/31/07, Ken Dunnington <[EMAIL PROTECTED]> wrote:
So I wrote up a quick test case, and it seems that added items to the
linked iterator of a child object do not get saved when the parent object's
save() method is called.
<cfoutput>
<cfset profile = reactor.createRecord("Profile").load(id=1) />
<p>Got profile: #profile.getName()#</p>
<cfset mainRoom = profile.getMainRoom() />
<p>Main Room: #mainRoom.getName()#</p>
<p>Main Room isDirty status: #mainRoom.isDirty()#</p>
<cfset mainRoom.getProductIterator().deleteAll() />
<p>Main Room's ProductIterator has removed all records.
(#mainRoom.getProductIterator().getRecordCount()#)</p>
<p>Main Room isDirty status: #mainRoom.isDirty()#</p>
<cfset product = mainRoom.getProductIterator().add(id=1) />
<p>Added product: #product.getName()#
(#mainRoom.getProductIterator().getRecordCount()#)</p>
<p>Main Room isDirty status: #mainRoom.isDirty()#</p>
<!---
<cfset mainRoom.setName(CreateUUID()) />
<p>Changed name to #mainRoom.getName()#</p>
<p>Main Room isDirty status: #mainRoom.isDirty()#</p>
--->
<cfset profile.save() />
<p>Saved profile.</p>
</cfoutput>
If I uncomment the last setName() line, everything works as expected.
Otherwise, the linked references are deleted (via the deleteAll() method)
and no new records added. After adding items to the iterator, the isDirty
status of the Room record remains "NO". Shouldn't modifying the iterator
change the isDirty status of its parent? Maybe I just don't understand how
cascading saves work?
On 1/31/07, Ken Dunnington <[EMAIL PROTECTED]> wrote:
>
> Nothing happens. There are no errors or anything, and after I call
> save() on the iterator, it still shows that it contains the right
> information, but the link table is never updated. I should mention that I'm
> using the latest SVN build, am running in development mode, and I cleared
> out my project files.
>
> Okay, I just tried something that may shed light on the problem (and on
> new ones, no doubt :)) If I call save() on the Room records, the data in the
> iterator is saved. Also, if I alter a property of the Room record (via the
> form or otherwise) and then call save on the Profile record, the iterator is
> saved properly. However, if I submit the form without making any changes, or
> *only* selecting Products from the select list, the data from the iterator
> is erased from the database.
>
> I think I need to deconstruct my form logic, I'm obviously missing
> something here. I'll work up a much simpler test case.
>
> On 1/30/07, Doug Hughes <[EMAIL PROTECTED]> wrote:
> >
> > What happens if you call save() directly on the iterator?
> >
> > Doug
> >
> > On 1/30/07, Ken Dunnington < [EMAIL PROTECTED] > wrote:
> >
> > > I'm trying to add/update a linked relationship, but am having some
> > > trouble. I can add records to the iterator and verify they are the correct
> > > ones, but calling save() on the parent record doesn't seem to work. My
> > > config looks like this:
> > >
> > > <object name="Profile">
> > > <hasMany name="Room">
> > > <relate from="id" to="profileID" />
> > > </hasMany>
> > > </object>
> > > <object name="Room">
> > > <field source="roomType" field="value" alias="typeName"
> > > />
> > > <hasOne name="Profile">
> > > <relate from="profileID" to="id" />
> > > </hasOne>
> > > <hasOne name="roomType">
> > > <relate from="type" to="id" />
> > > </hasOne>
> > > <hasMany name="Product">
> > > <link name="roomItems" />
> > > </hasMany>
> > > </object>
> > > <object name="roomItems">
> > > <hasOne name="Room">
> > > <relate from="roomID" to="id" />
> > > </hasOne>
> > > <hasOne name="Product">
> > > <relate from="productID" to="id" />
> > > </hasOne>
> > > </object>
> > >
> > > I have a multi-select list in my form that displays all Products,
> > > and I'm handling the commit in my controller for now (this is where my
> > > fileService lives, and there are multiple file uploads.) This is how I'm
> > > adding Product records to the Room object's Iterator:
> > >
> > > mainRoom.getProductIterator().add(id=allValues[name])
> > > where allValues[name] traces out to the ID of the Product I select
> > > in the form. I can then verify this works like so:
> > >
> > > arguments.event.trace("Main: Product Name",
> > > mainRoom.getProductIterator().getNext().getName())
> > >
> > > This room record is obtained from a profile record which is working
> > > fine, so I don't understand why, when I call profile.save (), it's
> > > not cascading down to the productIterator. The other values in the Room
> > > records are saving properly. Anyone have any thoughts on what I'm doing
> > > wrong?
> > >
> > > --
> > > Suppose you were an idiot. And suppose you were a member of
> > > congress. But I repeat myself.
> > > -- Mark Twain
> > >
> > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > > -- -- -- --
> > > Reactor for ColdFusion Mailing List
> > > [email protected]
> > > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > > -- -- -- --
> >
> >
> >
> >
> > --
> > Doug Hughes
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- -- -- --
> > Reactor for ColdFusion Mailing List
> > [email protected]
> > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- -- -- --
> >
>
>
>
> --
> Suppose you were an idiot. And suppose you were a member of congress.
> But I repeat myself.
> -- Mark Twain
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- -- --
> Reactor for ColdFusion Mailing List
> [email protected]
> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- -- --
>
--
Suppose you were an idiot. And suppose you were a member of congress. But
I repeat myself.
-- Mark Twain
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
--
Doug Hughes
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --