Nathan,
In your menu gateway, you are assigning variables.dsn to be the result
of getDsn() on your "dsn" object - which is probably returns a string.
Then, later, you are trying to call getDsn() on this string (within
your cfquery tag).
I think what tripped you up here is naming conventions. "dsn" means
"datasource name". So to have a class called "dsn" is confusing,
especially if you have a getDsn() method inside. I bet if your class
was named "DatasourceConfig' or "DatasourceSettings", or anything
other than "dsn" you probably wouldn't have made this minor mistake.
I don't recommend adding debug statements to the core files - it may
execute things in an order that you don't expect and confuse you even
more. The error you were getting was pointed to exactly the line in
your code where it was happening, and ColdSpring had already wired
everything together and was out of the way by the time the error
occured. I would say it's better to put debug statements in your code
(probably in your init() and setter-methods) to see if the dependency
resolution is occuring as you expect.
Lastly, yes, ColdSpring is great to use in a remoting enviroment -
there's a section on it in the docs. We plan on adding some
Flex2-specific tips soon.
thanks,
Dave Ross
(I would rename this class to "datasourceBean" or something else -
"dsn" means "datasourcename"
On 7/5/06, Nathan Drury <[EMAIL PROTECTED]> wrote:
Hi
First I will ask if Coldspring can be used with a CF backend that will be
accessed via Flex 2 using remoting. If so, great, because I really like the
ideas behind Coldspring and AOP. If not, plese ignore the rest of this
email :)
I've created an app that will be used as a back end for Flex. At this stage
however I am just creating a few DAO / Gateways and am testing them as a
normal html web app. However, I cannot get it to work. I've created a
ModelGlue app in the past and it worked fine with Coldspring (thanks Sean
Corfield). But this app is not to use any framework and I cannot get it to
work with Coldspring. Here is what I have done so far (using my
MenusGateway.cfc as the cfc I'm trying to inject my datasource name into):
coldspringServices.xml
<beans>
<bean id="dsn"
class="com.tq.utils.db.dsn">
<property name="dsn" type="string"><!-- uses get/set -->
<value>THEZOO_DATASOURCE</value>
</property>
</bean>
<bean id="menusGateway"
class="com.tq.utils.menu.MenusGateway">
<property name="dsn">
<ref bean="dsn"/>
</property>
</bean>
</beans>
Application.cfc
<cffunction name="onApplicationStart">
:
<cfset application.serviceFactory = createObject( "component",
"coldspring.beans.DefaultXmlBeanFactory").init()/>
<cfset
application.serviceFactory.loadBeansFromXmlFile(application.serviceDefinitionLocation)/>
:
</cffunction>
MenusGateway.cfc
<cfcomponent>
<cffunction name="setDSN" returntype="void" access="public"
output="true">
<cfargument name="dsn" type="com.tq.utils.db.dsn"
required="true" />
<cfoutput>setDSN</cfoutput>
<cfset variables.dsn = arguments.dsn.getDSN() />
</cffunction>
<cffunction name="getAll" returntype="com.tq.utils.menu.Menus[]">
<cfset var qRead="">
<cfquery name="qRead"
datasource="#variables.dsn.getDSN()#">
QUERY HERE
</cfquery>
:
:
</cfquery>
</cffunction>
</cfcomponent>
I also added some outputs to DefaultXmlBeanFactory.cfc's
loadBeanDefinitions:
<cfoutput>beanIx: #beanIx#,
beanAttributes.id:#beanAttributes.id#,
beanAttributes.class:#beanAttributes.class#<br></cfoutput>
and BeanDefinition.cfc's addProperty function:
<cfoutput>addProperty:
#arguments.property.getName()#<br></cfoutput>
to get some debug
When I call MenusGateway's getAll function I get:
beanIx: 1, beanAttributes.id:dsn, beanAttributes.class:com.tq.utils.db.dsn
addProperty: dsn
beanIx: 3, beanAttributes.id:menusGateway,
beanAttributes.class:com.tq.utils.menu.MenusGateway
addProperty: dsn
But then it throws the error referring to the qRead query line in
MenusGateway.cfc:
Element DSN is undefined in a Java object of type class [Ljava.lang.String
So I thought I had it all set up properly, but it appears not. Does anyone
have any suggestions?
Thanks
Nathan Drury
Systems Analyst / Developer
Tourism Queensland - ICT
* [EMAIL PROTECTED]
( +61 7 3535 5037