cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tomi NA" <>
Subject Re: modifying relationship list
Date Mon, 19 Jun 2006 10:22:29 GMT
On 6/19/06, Andrus Adamchik <> wrote:
> Actually Cayenne allows you to easily implement a generic event
> mechanism. IMO this is much more powerful than regular Java Beans
> approach, although requires some understanding of how things work.
> In "cayenne classic" (DataContext/DataObject) you can implement a
> generic event mechanism in one place in a superclass that works
> consistently for all objects. You do that by overriding methods in
> DataObject interface (writeProperty). No need to put your code in the
> individual setters. It is up to you how you fire the events (you can
> fire two complimentary events on relationship change if you want).

Are you saying that this would be sufficient i.e. it'd fire the
expected events in the problematic case Martin pointed out?

    public void writeProperty(String propName, Object val) {
        Object oldVal = readProperty(propName);
        super.writeProperty(propName, val);
        firePropertyChangeEvent(propName, oldVal, val);

> Another way that works in both DataContext and CayenneContext and
> will likely become a default way after 1.2, is overriding
> ObjectContext.propertyChanged(..) method to fire the events. This
> allows to track all events by context in addition to tracking events
> of individual objects. IIRC there are limitations using this with
> DataContext, but it should fully work in CayenneContext.
> In other words tracking object changes is one of the hidden strengths
> of Cayenne. I wish it wasn't so hidden, so if anyone volunteers to do
> a tutorial or an example based on real experience, you'll be very
> welcome.

Wish I had the knowledge to put together such a tutorial. :)
If anyone here binds cayenne objects via jgoodies binding we could
exchange experiences, try to write a coherent two-page tutorial and
leave it to you to add the "coherent" part to the "two-page" part. :)



View raw message