Custom Application ADF Library Overrides
Contents
Overview
You should have learned that you can "inject" ADF Library Components into your application. However, you can also override ADF Library Components and deliver that override with your application.
Why would you override an ADF Library Component
There are many reasons to override an ADF Library Component in your application. One of those reasons is to make a minor modification to the ADF Library Component without affecting other applications/code that use the original component.
Steps to override
- Create a directory called "lib" in your applications "components" directory (e.g. /myApp/components/lib)
- Copy your ADF Library Component from its directory and place it int your /myApp/components/lib/ directory
- Modify the <cfcomponent> tag to extend the original ADF Library Component. For example, if you wanted to modify data_1_0.cfc in your application the <cfomponent> tag would be changed from this:
<cfcomponent extends="ADF.core.Base">
to:
<cfcomponent extends="ADF.lib.csData.csData_1_0">
Best practices
You don't have to override the entire component, you can add new methods and override existing methods pretty easily. Using the above example, lets say you wanted to modify just the "getStandardMetadata()" function so it would return more data than it does now. A sample of your csData_1_0 (located in the /myApp/components/lib/ directory) would look like this:
<cfcomponent displayname="CSData" extends="ADF.lib.csData.csData_1_0"> <cfproperty name="version" value="1_0_0"> <cfproperty name="type" value="singleton"> <cfproperty name="data" type="dependency" injectedBean="data_1_0"> <cffunction name="getStandardMetadata" access="public" returnType="query"> {your changes here} </cffunction> </cfcomponent>
Notice how the value of the "extends" attribute is pointing to the csData_1_0 component loaded into the ADF and notice how there are no other methods in this component. By extending the original csData_1_0 component, you automatically gain all of the methods defined in that component - so you need not copy those in.
This allows you to take advantage of any changes made to csData_1_0 automatically.