Hi everbody,
I have been trying to inject a Service depending on a rc variable. My actual setup looks like this.
+ handler
...
+ modules
+ api
+ handlers
+ question.cfc
+ model
+ QuestionService.cfc
+ AnotherService.cfc
After readin http://wiki.coldbox.org/wiki/Models.cfm and http://wiki.coldbox.org/wiki/WireBox.cfm i tried to inject AnotherService in the init function but couldn’t get it done, what am i doing wrong.
`
component name=“Question” extends=“core.handlers.CommonRest” {
property name=“QuestionService” inject=“QuestionService”;
//REST Allowed HTTP Methods Ex:
this.allowedMethods = {
index=‘GET’,
info=‘GET’
};
function init(event,rc,prc) {
injector = createObject(“component”,“coldbox.system.ioc.Injector”).init();
QuestionService = injector.getInstance("model."&rc.Service);
}
function index(event,rc,prc) {
response = QuestionService.list(rc.userUid);
prc.response.data = response.response;
}
function notinset(event,rc,prc) {
response = QuestionService.notinset(rc.userUid,rc.setUid);
prc.response.data = response.response;
}
function info(event,rc,prc){
prc.response.data = {name=“QuestionService”};
}
}
`
as always any help is very appreciated.
greets