Adding objects to generic object reference in onPersist()
Anton Pirker <[email protected]> Wed, 05 Sep 2007 12:58:10 +0200
| Newsgroups | gmane.comp.java.helma.general |
|---|---|
| Message-ID | <[email protected]> |
Hi List!
I have a Prototype 'Change'. This is some sort of changelog for
HopObjects. I add it to Objects via a generic object reference (as
described at [1])
Everythink works fine if i add the Change the normal way to my object, like:
var venue = new Venue("Supervenue");
var ch = new Change(u);
venue.changes.add(ch);
But i want to add the Changelog automatically. So i wrote a onPersist()
in HopObject.
So everytime when i store something i do the following:
function onPersist() {
//check if we have a collection
//to store the changes to
if(this.changes) {
//create the change and add it.
var ch = new Change(u);
this.changes.add(ch);
}
}
But the Change is not stored into the Database and I do not get an error
message.
I think it is because onPersist is called right before the object is
stored. So when a create a 'Change' object and add it to a
'changes'-collection of this in onPersist this does not have an finale
id and so the 'Change'-Object does not know who his parent is.
I also wrote a little demo-app to explain it a little better.
Does anyone know how i can achieve this, or i what i am doing wrong?
Thanks in advance!
Anton
[1] http://helma.org/bugs/show_bug.cgi?id=516
_______________________________________________
Helma-user mailing list
[email protected]
http://helma.org/mailman/listinfo/helma-user
onpersist.zip
(application/octet-stream, 2.2 KB) - not displayed