I am learning Coldbox (v 2.6.3). and rewriting a small application to
ColdBox. I use the CB functionality in my controllers and views by
just calling CB functions - getDatasource(), getColdBoxOCM(), getPlugin
('sessionManager') etc. That works fine. However, I don't succeed in
using the CB functionality also in my model cfc's.
For example: In my text.cfc in the model directory I call a method
'getContentObject' which reads from a DB table. I want to pass the dsn
name to the cfquery tag using getDataSource
('myDataSourceAlias').getName() instead of hardcoding it but all I get
is a CB error message:
'Variable GETDATASOURCE is undefined.'
along with a stack trace up to the location in my componient where the
If I do this:
in my event-handler (handlers/myEventHandler.cfc) or in a view (views/
myView.cfm) it prints the name of the data source as expected.
I don't have access to the CB functionality in some parts of my
application although I deployed my app in the directorystructure as CB
expects it to.
I figured: Since the event handler extends the
coldbox.system.eventhandler component,my model should extend
coldbox.system.eventhandler as well in order to be able to use CB
functionality here. Is this correct?
Problem is, I already extended this component (it is a rewrite of an
existing app) and CF does not know multiple inheritance. What is the
best way to get access to CB functionality in my model cfc's?
I probably miss some knowledge of CB that may solve this problem so
please educate me