1

I am creating a sub-application that is inside of an overarching application that contains an Application.cfc (that I can't modify). FW/1 requires an Application.cfc to extend in order to work. How would I go about having a Application.cfc for FW/1 while also making sure the overall Application.cfc runs?

  • You can't put the FW/1 application in its own directory? – David Faber May 18 '15 at 21:15
  • I can put it in it's on directory, but I need to inherit all of the items of the root Application.cfc as well as extend the framework.one component. – user3899606 May 19 '15 at 13:38
  • I'm not sure how workable that is. CF won't support multiple inheritance without some monkeying around. Is it possible to have `framework.cfc` extend the root `Application.cfc`? – David Faber May 19 '15 at 14:43

1 Answers1

0

The Application.cfc can be treated similar to other coldfusion components. So you can extend your component from the root Application that way you inherit all the methods from the root cfc. Just be sure that in any methods that you implement to also first call the parent method with the super keyword.

You may have to fiddle around getting the correct path or may need to create a CFC mapping depending on how the server is setup.

So inside your Application.cfc and assuming the other Application is one level up in your folder hierarchy.

<cfcomponent extends="../Application">
    <cffunction name="onRequestStart" returnType="boolean" output="true">
        <cfset var tmp = super.onRequestStart()>
        <cfreturn tmp>
    </cffunction>
</cfcomponent>
M.Scherzer
  • 921
  • 7
  • 9
  • This wouldn't work. To create a FW/1 application, the Application.cfc must extend the framework. The sub application cannot extend both the parent application and the framework. – Twillen May 19 '15 at 13:38
  • but if you have control over the FW/1 application you could just alter the framework application to extend from the parent. Although I don't know enough about the constraints you have to work with if that is an option for you. Another avenue to explore would be to instantiate the parent application like any other cfc. and just call the required methods within your own Application.cfc If you think that would work for you I will amend my answer with an example. – M.Scherzer May 20 '15 at 03:36