Re: modifying relationship list

From: Tomi NA (hefes..mail.com)
Date: Mon Jun 19 2006 - 06:22:29 EDT

  • Next message: Lothar Krenzien: "Re: IllegalStateException in DataRowStore (thrown by LRUMap)"

    On 6/19/06, Andrus Adamchik <andru..bjectstyle.org> 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. :)

    t.n.a.

    t.n.a.



    This archive was generated by hypermail 2.0.0 : Mon Jun 19 2006 - 07:08:48 EDT