RE: Track changes of a dataobjects property

From: Fredrik Liden (flide..ranslate.com)
Date: Thu Apr 21 2005 - 21:41:56 EDT

  • Next message: Jürgen Saar: "Re: Hierarchical relationship problems"

    Dang, how do you know all this? :-)

    Maybe I'll go with the first one then. According to the api the
    getCommittedSnapshot() and getCurrentSnapshot() of the DataObject are
    deprecated so it's recommended to use
    getDataContext().getObjectStore().getSnapshot(this.getObjectId(),
    getDataContext()) and getDataContext().currentSnapshot(this)
    respectively, in case anyone is interested.

    I dig the listener thing but not sure I can get it to work but I'm
    curious.
    How do I register the listener in the DataView? Is the dataview some
    context held object? Or is it one dataview per application?
    I can't seem to find a method to retrieve it.

    Hey what's so uncool about the third method. That's a good idea right?
    perhaps add a convenience method that returns a list of the modified
    fields based on the getCommittedSnapshot() and getCurrentSnapshot()
    methods. If I'm halfway into development, would there be any problems
    creating my own CayenneDataObject? Like having to do any casting etc?

    -----Original Message-----
    From: Cris Daniluk [mailto:cris.danilu..mail.com]
    Sent: Thursday, April 21, 2005 5:52 PM
    To: cayenne-use..bjectstyle.org
    Subject: Re: Track changes of a dataobjects property

    You can access the snapshot and compare directly... not sure if that
    works for you or not. getCommittedSnapshot() and getCurrentSnapshot()
    can give you the differences.

    There's also the un-documented but very present FieldValueChangeEvent
    that you could use. Just register it in the DataView, and then use it to
    collect the modifications for later review. It's a funky way to get to
    what you want, but if you need more realtime access to property changes,
    it's an elegant way to do it.

    A slightly more intuitive but less cool way to do it is to just change
    the superclass you use from CayenneDataObject to your own, and wrap
    writeProperty.

    Still, from the sounds of what you're doing, the snapshot should be all
    you need...

    On 4/21/05, Fredrik Liden <flide..ranslate.com> wrote:
    > Does anyone know if it's possible to track changes of the individual
    > properties of a data object? I know there is the get persistence state

    > but it's for the whole object. I'm trying to do some custom
    > validations in a validateForUpdate method and allow only certain
    > fields to be modified. Just wondering.
    >
    > Thanks,
    >
    > Fredrik
    >



    This archive was generated by hypermail 2.0.0 : Thu Apr 21 2005 - 21:40:25 EDT