I am trying to get coldbox to inject the property of a setting into a script component. I’ve included my code below. However, each time I call getMyFunction() it throws an error stating that getDatasource is null instead of my coldbox setting. It appears that _wireme and autowire isn’t being executed. Any ideas?
/**
*@accessors true
*@displayname User
*@output false
*@autowire true
*@hint A user object
*/
component
{
/
*@setter true
*/
property name=“datasource” type=“string” _wireme=‘coldbox:setting:myDatabaseSetting’;
public user function init()
{
return this;
}
public query function getMyFunction(numeric id)
{
var strSql = “SELECT * FROM data WHERE id = :id”;
var query = new Query();
query.setDatasource(getDatasource());
query.setSql(strSql);
query.addParam(name=“id”,value="#arguments.id#");
I’m running CB3 latest github updates (rc2?) anyways, I copied and pasted the response from curt and it worked perfectly after that…very strange, I must have had a type-o.