RE: Re: Re: Re: [coldbox:24238] Re: [Coldbox 4] modelsLocation and modelsExternalLocation

Can you show us your config for that? It should look like this:

http://wiki.coldbox.org/wiki/ConfigurationCFC.cfm#conventions

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

// Configure ColdBox Application
function configure(){

// coldbox directives
coldbox = {
//Application Setup
appName = “MyApp”,
eventName = “event”,

//Development Settings
debugMode = true,
debugPassword = “”,
reinitPassword = “”,
handlersIndexAutoReload = true,

//Implicit Events
defaultEvent = “admin.index”,
requestStartHandler = “Main.onRequestStart”,
requestEndHandler = “”,
applicationStartHandler = “Main.onAppInit”,
applicationEndHandler = “”,
sessionStartHandler = “”,
sessionEndHandler = “”,
missingTemplateHandler = “”,

//Mappings
modelsLocation = “model”,
modelsExternalLocation = “global.model”,

//Extension Points
UDFLibraryFile = “includes/helpers/ApplicationHelper.cfm”,
coldboxExtensionsLocation = “”,
modulesExternalLocation = ["/coldbox/modules"],
//pluginsExternalLocation = “global.plugins”,
viewsExternalLocation = “”,
layoutsExternalLocation = “”,
handlersExternalLocation = “”,
requestContextDecorator = “RequestContextDecorator”,

//Error/Exception Handling
exceptionHandler = “utils.Error.onException”,
onInvalidEvent = “utils.Error.onInvalid”,
customErrorTemplate = “/coldbox/system/includes/BugReport.cfm”,

//Application Aspects
handlerCaching = false,
eventCaching = false,
proxyReturnCollection = false
};

Check the link to the docs I sent you. Those config items don’t go in the “coldbox” struct, but in the “conventions” struct.

/config/ColdBox.cfc
component {

function configure() {
coldbox = {
modelsExternalLocation = “global.model”,
};
conventions = {
modelsLocation = “model”,
};
}
}

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Fantastic, that works modelsLocation, however modelsExternalLocation does not work in either the config struct or the colbox struct and it appears modulesExternalLocation works in either one?

I was mistaken when I said modulesExternalLocation worked either way, when I had modulesExternalLocation = ["/coldbox/modules"], in the coldbox config, it was working properly, I moved it to the conventions struct as a string and it does not seem to be scanning that location anymore modulesExternalLocation = “/coldbox/modules”

Back to the injection issue would I need to reference it in the same way I would for the getModel call?

property name=“SettingWrapper” persistent=“false” inject=“model:utility.SettingWrapper”;

There’s actually no such setting called “modelsExternalLocation”. You just made that one up :slight_smile: If you want additional model locations, just set them as scan locations in the WireBox config.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

property name=“SettingWrapper” persistent=“false” inject=“model:utility.SettingWrapper”;

Yes, that’s correct. The “model:” bit is actually optional. It redirects to the “id:” namespace, which is also the default.

So, what happens when you try this injection? Is there an error?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I was wondering about that, perhaps it was deprecated at some point? I have found several references to it.

https://groups.google.com/forum/#!topic/coldbox/IfIRcOqV8Mohttps://books.google.com/books?id=4HyYFki2Ji4C&pg=PA214&lpg=PA214&dq=modelsExternalLocation&source=bl&ots=pcYqMx9ZJI&sig=GI-2n-00iZiy7jkkz0dJoRzE90E&hl=en&sa=X&ei=UN1LVZChGILvggTLmoDoAw&ved=0CCUQ6AEwAQ#v=onepage&q=modelsExternalLocation&f=false

Ahh, yes it used to exist back in the days before WireBox. It was removed at some point.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

in my orm entity the model is injected like this

property name=“SettingWrapper” persistent=“false” inject=“model:utility.SettingWrapper”;

I have a simple method that returns this SettingWrapper.setMemento( getSettingMemento() )

which results in the following error

coldfusion.runtime.UndefinedVariableException: Variable SETTINGWRAPPER is undefined.

Where is that method call? You can’t use injected variables in the pseduo constructor or the init().

Also, how are you creating the ORM entity?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Its not in the init function, its just a public function on the entity center.cfc. I have not really changed anything about the way the orm entity is being created as it was working properly in 3.5.3 below is a stripped down example of what I am looking at on the orm cfc

component entityname=“Center” table=“Center” extends=“myapp.model.orm._Base” persistent=“true” {

property name=“SettingWrapper” persistent=“false” inject=“utility.SettingWrapper”;

/**

  • Gets instance of SettingWrapper, which has utils for handling the memento
  • return SettingWrapper
    */
    public Any function getSettingHelper() {
    return SettingWrapper.setMemento( getSettingMemento() );
    }

if I dump the center object right before it tries to access it and errors out I can see that it has the property but not the settingswrapper object, which is why I keep thinking there is something wrong with the way I am injecting it.

OK, so if there is no error autowiring the ORM entity, yet the dependency is not defined, that tells me that autowire is not happening. I need to know how you are creating the ORM entity. My first guess is that your ORM even listener is not configured correctly in Application.cfc. Please confirm the following:

  • cborm module is installed
  • /cborm CF mapping created in Application.cfc that points to the root of the module
  • Make sure you have this.ormSettings.eventHandler = “cborm.models.EventHandler” set in Application.cfc

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

got it!, I was pointed to this.ormSettings.eventHandler = “cborm.models.ORMEventHandler” instead of just EventHandler, thank you very much for your help kind sir.