Help needed with referencing external models

23 views
Skip to first unread message

Gary

unread,
Feb 7, 2012, 4:17:09 PM2/7/12
to col...@googlegroups.com
I am running Coldbox 3.1 on a local WindowsXP machine running CF9. I am going to be building multiple Coldbox apps and want to have a centralized location for some of the models that the apps will all need. But I've been unable to call any of these models. Here's what I've done:

My web root looks like this:

- app1
- app2
- sharedstuff

In app1.config.Coldbox.cfc I did this:

modelsExternalLocation = "sharedstuff.model",
I also tried this:

modelsExternalLocation = "D:\Programs\Coldfusion9\wwwroot\sharedstuff\model",
In app1.model.User.cfc, I have this:

component name="User" {
property name="sharedUser" type="model" scope="instance";
public struct function getUser(){
var user = instance.sharedUser.getGlobalUser();
return user;
}
}
My assumption is that since I have specified the external location, that the property call to sharedUser should work since Coldbox would look in the external location for sharedUser.cfc. But that doesn't seem to be happening.

The error I get is:

Element SHAREDUSER is undefined in a Java object of type class [Ljava.lang.String;.
Any help will be much appreciated!

br...@bradwood.com

unread,
Feb 7, 2012, 4:31:29 PM2/7/12
to col...@googlegroups.com
Have you created a CF mapping for called "sharedstuff" that points to D:\Programs\Coldfusion9\wwwroot\sharedstuff\model?

~Brad
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

Gary

unread,
Feb 7, 2012, 4:38:09 PM2/7/12
to col...@googlegroups.com
I hadn't done that, but I have now, but am still seeing the same error. I made sure to reboot CF and Coldbox after the change, just in case.

br...@bradwood.com

unread,
Feb 7, 2012, 5:18:59 PM2/7/12
to col...@googlegroups.com
Looking quickly at the code, I'm not actually sure if Wirebox even uses the modelsExternalLocation setting.  It's only referenced in the legacy bean factory code.

Set up your external folder as a scan location in your binder config in /config/wirebox.cfc.

// Package scan locations
scanLocations = ['sharedstuff.model'],

Now, if you reference a model named "foobar.BarService", it will be looked for in "sharedstuff.model.foobar.BarService".

Thanks!

~Brad
-------- Original Message --------
Subject: Re: [coldbox:13669] Help needed with referencing external
models
From: Gary <garyt...@gmail.com>

Gary

unread,
Feb 8, 2012, 9:37:10 AM2/8/12
to col...@googlegroups.com
Hi Brad,

Thanks for all your help. Unfortunately, it's still not working. Here's a summary of what I have in place:

CFAdmin
----------------
mapping of /SharedStuff  to  D:\Programs\Coldfusion9\wwwroot\SharedStuff


Wirebox.cfc
------------------
// Package scan locations
scanLocations = ['SharedStuff.models'],


app1.model.User.cfc
--------------------------------
component name="User" {
property name="GlobalUser" type="model" scope="instance";
// get the data for the user accessing the site
public struct function getUser(){
var user = instance.GlobalUser.getGlobalUser();
return user;
}
}

sharedStuff.models.globalUser.cfc
------------------------------------------------------
component name="GlobalUser" output=true {
// get the data for the user accessing the site
public struct function getGlobalUser(){
return {
name = "testnamehere"
};
}
}

Error message:  Element GLOBALUSER is undefined in a Java object of type class [Ljava.lang.String;.


br...@bradwood.com

unread,
Feb 8, 2012, 10:22:56 AM2/8/12
to col...@googlegroups.com
This is the wrong injection syntax:

property name="GlobalUser" type="model" scope="instance";

Should be
property name="GlobalUser" inject="model" scope="instance";

Also, how are you creating the instance of your user CFC?  You need to be getting it via the framework, and not createObject() or it will not be injected with its dependencies.

Thanks!

~Brad

-------- Original Message --------
Subject: Re: [coldbox:13679] Help needed with referencing external
models
From: Gary <garyt...@gmail.com>

Gary

unread,
Feb 8, 2012, 10:44:57 AM2/8/12
to col...@googlegroups.com
Hi Brad,

Problem fixed! I was indeed the wrong syntax for the property tag. Everything works like a charm now.

Thanks again for all your help.

Gary

br...@bradwood.com

unread,
Feb 8, 2012, 10:46:35 AM2/8/12
to col...@googlegroups.com
Glad to hear it's working.  Happy injecting!

~Brad
-------- Original Message --------
Subject: Re: [coldbox:13685] Help needed with referencing external
models
From: Gary <garyt...@gmail.com>
Reply all
Reply to author
Forward
0 new messages