event.getCurrentPackageHandler()

I’m looking for a method such as event.getCurrentPackageHandler() that would return…

“mypackage.myhandler”

…for the request…

http://mydomain.com/index.cfm?event=mypackage.myhandler.myaction

I know I could trim the event off of the end of event.getCurrentEvent() but would prefer an in-built function if there is one that I can’t find!

Richard

you can create a request context decorator and put the method there.

Humm, that’s an interesting idea!

The wiki website is down for me right now so from memory I’ve added coldbox.requestContextDecorator=“model.requestContextDecorator” to my Coldbox.cfc and then created this…

component extends=“coldbox.system.web.context.requestContextDecorator” {
public string function getCurrentPackageHandler(required string currentEvent) {

return listDeleteAt(arguments.currentEvent, listLen(arguments.currentEvent, ‘.’), ‘.’) ;
}
}

…and then tried to use this in my handler…

prc.strAddLink = “#getCurrentPackageHandler(event.getCurrentEvent())#.add”;

…but get…

No matching Method/Function for GETCURRENTPACKAGEHANDLER(string)

I guess I’m referencing it wrongly?

Richard

try reinit’ing the app.

also, you dont have to pass in the currentEvent. in your method, you could just call getCurrentEvent().

the request context decorator decorates your event object.

arguments.event.getCurrentPackageHandler(); is how you would reference it.