Injecting entity services to Request Context Decorator

Is it possible to inject entity services to Request Context Decorator, like this:

component name=“RCDecorator” extends=“coldbox.system.web.context.RequestContextDecorator” autowire=“true” {
property name=“userService” inject=“entityService:User”;

public any function getUser(userId) {
return userService.getUser(userId);
}
}

Hey Nick, I am guessing you have tried it. My guess is that the decorator is setup before injection takes place as it is part of the core of ColdBox, I would guess no. Unless something in ColdBox 4.x has changed this… Brad?

No, the request context decorator is built outside of WireBox. However, the reuqest context decorator constructor receives and instance of the ‘controller’. So you can manually call wirebox via the constructor and setup your dependencies.

Arguments.controller.getWireBox().getInstance()

Hmm… I can see the controller in the constructor arguments, but can’t see the getWireBox() method.

I’m using 4.1.0.

Thanks.

http://apidocs.ortussolutions.com/coldbox/4.1.0/coldbox/system/web/Controller.html#getWirebox()

Luis Majano
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057

Thanks got it now.

Nick,

Could you post the answer/solution to the problem? I’m curious. Thanks.