Here's a simple a test case:
<beans>
<bean id="Factory" class="testing.Factory">
</bean>
<bean id="Child" factory-bean="Factory" factory-
method="create">
<property name="Property">
<value>400</value>
</property>
</bean>
</beans>
ColdSpring throws an error:
The VALUE parameter to the setProperty function is required but was
not passed in.
/coldspring/beans/DefaultXmlBeanFactory.cfc: line 940
/coldspring/beans/DefaultXmlBeanFactory.cfc: line 632
Can you not use property elements on factory-bean results?
The trace returns {'p':'','Property':'400'} from setProperty() in
bean.cfc created by Factory.cfc
cs.xml
<beans>
<bean id="Factory" class="Factory">
</bean>
<bean id="Child" factory-bean="Factory" factory-method="create">
<property name="Property">
<value>400</value>
</property>
</bean>
</beans>
bean.cfc:
<cfcomponent>
<cffunction name="init" access="public">
<cfreturn this>
</cffunction>
<cffunction name="setProperty" access="public">
<cfargument name="p" default="" />
<cftrace var="arguments" />
</cffunction>
</cfcomponent>
Factory.cfc:
<cfcomponent>
<cffunction name="init" access="public">
<cfreturn this>
</cffunction>
<cffunction name="create" access="public">
<cfreturn createObject("component", "bean").init()>
</cffunction>
</cfcomponent>
<cfset cs = createObject("component",
"coldspring.beans.DefaultXmlBeanFactory").init() />
<cfset cs.loadBeansFromXmlFile( beanDefinitionFile: "cs.xml") />
<cfdump eval="cs.getBean('Child')" />
--
/Kevin Pepperman
"They who can give up essential liberty to obtain a little temporary
safety, deserve neither liberty nor safety." - Benjamin Franklin
Property = 400
method setProperty() in bean.cfc called from CS factory-method
"create" in Factory.cfc
<cffunction name="setProperty" access="public">
<cfargument name="Property" default="" />
<cfdump var="#arguments#" />
<cfabort />
</cffunction>
Are you running 1.2 or BER? We're on 1.2 and this fails on 2 different
servers.
On Mar 7, 5:08 am, Kevin Pepperman <chorno...@gmail.com> wrote:
> Just tested CF9, and it works there too..
http://elliottsprehn.com/personal/coldspringfail.zip
Here's a sample app. It fails in both CF8 and CF9 with the same error
listed above.
I just checked out from CVS (following the instructions on the
website) and I still see this failure.
After playing with this some I've found that this does work:
<cffunction name="setProperty" access="public" returntype="void"
output="false">
<cfargument name="property" type="any" required="true">
<cfset variables.property = arguments.property>
</cffunction>
And dumping the arguments shows that too. So CS is passing the
argument name as the name of the property which is totally wrong
instead of using the name of the first argument, or even name="1"
which would work too. Your test case passes because you have
default="" and not required="true".
I tracked that down into BeanProperty.cfc#getArgumentName()
<cffunction name="getArgumentName" access="public" output="false"
returntype="string" hint="I retrieve the Name from this instance's
data">
<cfif structKeyExists(variables.instanceData,"argName")>
<cfreturn variables.instanceData.argName/>
<cfelse>
<cfreturn getName() />
</cfif>
</cffunction>
which is returning getName() if there's no name. It should return "1"
to get the first positional argument.
<cffunction name="setProperty" access="public" returntype="void" output="false">
<cfargument name="property" type="any" required="true">
<cfset variables.property = arguments.property>
</cffunction>
--
I'm sure someone knows more about it than I do and will chime in if it
is an actual bug.
I'm glad you have it working now.
--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To post to this group, send email to coldspri...@googlegroups.com.
To unsubscribe from this group, send email to coldspring-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/coldspring-users?hl=en.
If you want to maintain that level of backwards compatibility it just
needs to check if the property is real with structKeyExists() (allow
OnMethodMissing) and then use
getMetaData(beanInstance[prop]).parameters[1].name instead of
getArgumentName().
Only lines 939, 945 and 962 of DefaultXmlBeanFactory would need to be
updated. A pretty simple fix. :)
If you wanted to maintain that level of backwards compatibility it
just needs to check if the property is real with structKeyExists() and
then use getMetaData(beanInstance[prop]).parameters[1].name to grab
the name.
Lines 939, 945, and 962 just need to change in DefaultXmlBeanFactory
from using getArgumentName() to using that.
Apologies for the dup. Groups said it didn't go through. :/