Matt, thank you for your reply.
I have looked into using decorators, but have a few pretty big issues
with going that direction:

- Using an event observer means that I define my business logic in
*one* place, and maintain it in *one* place.  If I use decorators, I
have to define a decorator for every single object.  As I add more
objects, I have to add more decorators, instead of allowing the event
observer to dynamically determine what is happening, since it receives
events for ALL objects
- If I go the route you've suggested, I think I will have to add
custom methods for every single field on every single object.  Not
only does this mean that I would have to maintain many decorators (I
currently have around 30 tables in this database), but I would also
have to maintain many methods inside each and every decorator.
Transfer's easy XML configuration allows me to change my schema/ORM
quickly, but I would really slow changes down if I went this way,
since I would *at least* have to make changes in two places: the XML,
and the decorator/method.  If I'm adding a new object, then I have to
add a new decorator, define all it's "tracking" methods, etc.


Since Transfer is keeping track of the changes that I am making, isn't
there some way to extract from it the differences between the
persisted object, and the dirty object?  It has the isDirty() method,
does the internal logic stop there?

Thank you again; I look forward to your reply!

-Denver


On Aug 5, 2:44 pm, Matt Quackenbush <[email protected]> wrote:
> Use a decorator.  In it you can utilize a variety of techniques to track the
> "old" value and compare it with the "new" value.  For example...
>
> 1) Create an ActionAfterNewTransferEvent observer, which calls a method on
> your decorator.  I use configAfterNew() in mine.  For an example of how to
> register such an observer, I would recommend taking a look at the
> TDOBeanInjectorObserver in Brian Kotek's ColdSpringUtils project 
> (http://coldspringutils.riaforge.org/).
>
> 2) In your configAfterNew() method, set a local property (e.g. not part of
> the Transfer object itself) to the current value.  For example, I track
> changes to UserName.  So, in my UserDecorator, I have the following:
>
> <cffunction name="configAfterNew" returntype="void">
>      <cfscript>
>           setCurrentUserName(getUserName());
>      </cfscript>
> </cffunction>
>
> <cffunction name="getCurrentUserName" returntype="string">
>      <cfscript>
>           if ( ) {
>
>           setCurrentUserName(getUserName());
>      </cfscript>
> </cffunction>
>
>
>
> On Wed, Aug 5, 2009 at 2:30 PM, Denver <[email protected]> wrote:
>
> > Can anyone help with this???
>
> > -Denver
>
> > On Aug 3, 2:42 am, Denver <[email protected]> wrote:
> > > Hello,
> > > I am attempting to use event handlers to catch updates to my
> > > TransferObjects before they happen, so that I can log changes into a
> > > history table.
>
> > > So far I have set up a beforeUpdateObserver and the event being passed
> > > in allows me to access the object that is about to get saved to the
> > > database, but I can't figure out how to take a look at a pristine copy
> > > of that object.
> > > (i.e. I have a user, and I have changed his first name.  When I save()
> > > that user object, the beforeUpdateObserver is called, and I am able to
> > > access the object with the new first name, but I can't figure out how
> > > to see what his first name was before the change).
>
> > > What should I do?
>
> > > I have thought about cloning the changed object and then discarding
> > > it, retrieving a fresh copy of the object, and then comparing those,
> > > but that seems like a bad idea.
>
> > > Thoughts?
>
> > > -Denver Root
--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to