The other thread regarding decorators has moved well into the realm of new high-flying uses. My question is simpler, so I won't insert it into the middle of what's turned into a very interesting discussion.
Here's the thing: even after all the excellent explanations in that other thread, I'm still uncertain about when configure() runs, and whether to use it in certain instances.
Here's an abbreviated example:
I have a Case object (like a legal Case). There is an Attorney object which is related to it by a manytone tag in the Case object's definition.
Which means, of course, that there's no AttorneyID in the Case object definition, and thus no myCase.getAttorneyID() method (or "set," of course). It's myCase.getAttorney().getAttorneyID().
However, I am using Transfer Objects as Model-Glue event-beans. So it would be handy to have a setAttorneyID() method which would accept an AttorneyID passed from the form into the event.
That's simple enough to add to the Decorator. And that's my real need, so I'm happy.
<cffunction name="setAttorneyID" access="public" returntype="void" output="false">
<cfargument name="AttorneyID" type="numeric" required="true" />
<cfset variables.AttorneyID = arguments.AttorneyID />
</cffunction>
But as an exercise, I created a configure() method in my decorator, which contains the following:
<cfif getOriginalTransferObject().hasAttorney()>
<cfset setAttorneyID(getOriginalTransferObject().getAttorney().getAttorneyID()) />
</cfif>
(And by the way, since I'm uncertain of the syntax, I've tried both getTransferObject() and getOriginalTransferObject(). Which is correct in this case?)
So I would expect that if the Case object is an existing Case, with an Attorney relationship, the AttorneyID would populate and be available with getAttorneyID(). However, when I create a Transfer Object with get("cases.case",caseID), then call getAttorneyID(), I get an error saying that variables.AttorneyID is not defined.
Am I doing this incorrectly? Is it a bad idea? Or is it simply that configure() runs when the object itself is created, but before it is populated with the data from the database?
--
Thanks,
Tom
Tom McNeer
MediumCool
http://www.mediumcool.com1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560