All,
I'm trying to create a base handler that some of my other handlers
will extend. My base object will be injected an object that will then
be persisted in the rc. How could I do this? I need to be able to
access the event object (for RC scope) via my init() method in my base
handler?
<!--- This init is mandatory, including the super.init(). --->
<cffunction name="init" access="public" returntype="any"
output="false">
<cfargument name="controller" type="any">
<cfscript>
super.init(arguments.controller);
// Any constructor code here
rc.project = instance.MyService.getProjects(rc.projectid);
return this;
</cfscript>
</cffunction>
</cfcomponent>
I'm getting the following exception...
Element MYSERVICE is undefined in a Java object of type class
[Ljava.lang.String;
As you can see I don't have rc scope within my init(), can the event
object into this method? Also can base handlers be injected objects,
or do I need to use getModel() as my dependency method?
Hey, I'm a bit confused about what you're doing here. So, are you
trying to get the Event on init? If so, isn't init only fired on
handler creation, therefore not available on each request? If so,
what's the purpose of getting the event in init?
if you have a preHandler defined in each handler, the one in the Base handler won’t run, so if you want to put code in the Base handler to run on each request, you’ll want to do something like this in each one of your handlers that extends the Base Handler
@whostheJBoss, I have a base_handler that is populating an object init
so every sub handler doesn't have to. I just extend my base handler.
this is effin sweet when you doing nested routing in which I am!!
So, this object, rc.project in your example, are you keeping it in the
rc throughout all of the requests? If init only runs at handler
creation, then wouldn't rc.project only get created once and not on
future requests??