<!---To display artists home page--->
<cffunction name="home" access="public" returntype="void"
output="false" hint="displays an artists home page, with songs
listed">
<cfargument name="EVENT" type="coldbox.system.beans.requestContext">
<!---Reference to the request collection--->
<cfset var rc=event.getCollection()>
<!---Logic to Prepare View--->
<cfset rc.qryArtData = instance.mdl_artists.getArtistData
(rc.name_art)>
</cffunction>
mdl_artists is my model object I am trying to inject into
the artist handler above
However, I am getting the following error message when I
load the page....Element MDL_ARTISTS is undefined in a Java object of
type class [Ljava.lang.String;.
Im sure im doing this completely wrong, but would like to
get a hang of model integration.
2. Have you reinitialized the framework? When I add a new dependency
to an object, I sometimes get errors like that if I run the page after
adding the dependency. Reinitializing stitches it all back up
including my newly added dependency.
3. For pure troubleshooting purposes, try using an alternate way to call it.
But am now recieving an error message on my page, unsure what it
means..
Execution Exception
Error Type: Object : [N/A]
Error Messages: The containsBean method was not found.
Either there are no methods with the specified method name and
argument types, or the containsBean method is overloaded with argument
types that ColdFusion cannot decipher reliably. ColdFusion found 0
methods that matched the provided arguments. If this is a Java object
and you verified that the method exists, you may need to use the
javacast function to reduce ambiguity.
Don't know what's causing that. If I was troubleshooting the full
code, I'd attack like this:
a. Reinitialize the framework. I always like to check that off the
troubleshooting list. If it still doesn't work....
b. Create a new handler with one event and one view and try to inject
something much simpler (like a configuration setting). Create a
request collection variable that equals the injected value and verify
in your view's debug panel that the value was created. Once that's
working....
c. Change the injected dependency to a model. Again, verify in your
view's debug panel that the model was properly injected. Once that's
working.....
d. Start to add parts of the real handler into the test handler. Add a
little at a time [making sure you reinit the framework when things go
wrong :-)] and you should end up with your test handler working with
all of your original code and the model integration.
containsBean is only called when using an IoC framework integration, not model integration. Check if you have set one up or there any dependencies that have “ioc” in the type
Before I continue troubleshooting, would I need to have the setting
autowire="true" on the handler component, if I am injecting
dependancies from a model object?
I dont have any dependencies with ioc in the type....and have the
autowire inceterceptor set up like this
Hi there. I’m new to using CB’s model management aspect as well, but two things come to mind when looking at the error being thrown.
Did you define the model object in your modelMappings.cfm file? It’s my understanding that if I want CB to manage a model item, I need to tell it about it via the modelMappings.cfm (I could be wrong on that though);
Is it necessary to have defined “instance” in the constructor of the handler, as in putting “” just below the tag? In one example I saw of a model object having a bean injected via cfproperty, this was how it was being done, but in the handler example that bit of code wasn’t present. Wondering if it was just accidentally omitted from the example…
Not sure if you are meant to have anymore code in the file than this?
I have then tried
<cfset variables.instance = structnew() />
OR
<cfscript>
instance=structnew ( );
</cfscript>
just below the cfproperty tag... <cfproperty name="mdlArtists"
type="model" scope="instance" />
But I am still recieving the error message "Element MDLARTISTS is
undefined in a Java object of type class [Ljava.lang.String;.", when i
load up the page
I feel kind of silly now....just realised that the reason it wasnt
working was because I was using version 2.6.1 of coldbox where model
integration wasnt available..