Building DP CFCs: Step One: Extend the Root Component
The first step is to extend the root component ("cfc_DepressedPress.DP_Component") in all your DP CFCs. You do this with the extends attribute of the CFCOMPONENT tag like so:
<cfcomponent
displayname="Name of your CFC"
extends = "cfc_DepressedPress.DP_Component"
hint="Description of your CFC">
...component body...
</cfcomponent>
This immediately provides your CFC with the following variables:
- DPID: This is a unique ID value created using the CreateUUID() function but modified to allow it to act as a variable name or structure key.
- DPInit: This variable begins as "false" but is set to "true" upon the running of the super.Init() initilization function. It's useful for determining if a DP CFC has been populated with data (initialized) or not (uninitialized).
- DPCreated: A date/time stamp recording the time of the CFCs instantiation.
- DPLastAccess: Using the DP CFC method "touch()" you can update this value to easily track updates to your CFC instances. This is especially useful for determining lifespans of cached CFC instances.
In addition the CFC inheirits many potentially useful methods. These are detailed in the documentation for DP_Component but here are just a few.
- touch(): Updates the DPLastAccess date/time stamp for the CFC instance.
- getProp(): The generic getter. Allows the retrieval of DP CFC properties with or without specifically declared getters.
- setProp(): Allows the setting of DP CFC properies with type validation with or without specifically declared setters.
- isProp(): Allows the programmer to quickly determine if a property has been defined as a DP Property.
- dump() and dumpThis(): Allow CFDUMP to be used within CFScript.
Next your must define what properties you're CFC will have.