Page Controller 1.0 Documentation: Imitating Inheritance

Page Controller Information

Blog Entries

Check Out AFF

Imitating Inheritance

Imitating Inheritance

Note: This only works on ColdFusion 8 or better (requires onMissingMethod support).

Page Controllers need to inherit (directly or indirectly) the PageController.cfc. Sometimes, however, your page will be primarily interacting with one service. In that case, it might make sense for your Page Controller to act as a pass-through for that service. To seem to inherit from it, in fact.

So, for example to have your Page Controller pass missing methods to variables.ContactOMatic, use the following code:

<cfset setInherits(variables.ContactOMatic)>

A more complete example (including loading external variables) would be using the service in Application.ContactOMatic:

<cfset loadExternalVars("ContactOMatic")>
<cfset setInherits(variables.ContactOMatic)>

In each case, the code should go in the pseudo-constructer (after CFCOMPONENT, but before the first CFFUNCTION).