Custom Application ADF Library Overrides

From ADF Docs
Jump to: navigation, search


You should have learned that you can "inject" ADF Library Components (App Bean Config) 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

  1. Create a directory called "lib" in your applications directory (e.g. /myApp/lib)
  2. Copy your ADF Library Component from its directory and place it int your /myApp/lib/ directory
  3. 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">


<cfcomponent extends="ADF.lib.csData.csData_1_0">
  1. Update the application appBeanConfig.cfm to create a singleton for this component. The second parameter must be a unique bean name for the component. Add a dependency for this new bean into the application.
// Load the customized CSData for the application
addSingleton("ADF.apps.myApp.lib.csData_1_0", "myApp_csData");
addConstructorDependency(appBeanName, "myApp_csData", "csdata");

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}


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.