Ticket #312 (closed defect: fixed)
ollectionBeanPopulator.cfc erroneously checked for the existance of the key, arguments.properties, which held true even when the key was empty.
| Reported by: | DanWilson | Owned by: | somebody |
|---|---|---|---|
| Priority: | highest | Milestone: | |
| Version: | Severity: | blocker | |
| Keywords: | Cc: |
Description
Inline is a patched /ModelGlue/gesture/externaladapters/beanpopulation/CollectionBeanPopulator.cfc I changed the logic that chooses which method signature of the CollectionBeanMaker?.makeBean() method to use. Before, CollectionBeanPopulator?.cfc erroneously checked for the existance of the key, arguments.properties, which held true even when the key was empty. So this code:
<cfset arguments.event.makeEventBean( filter) />
would effectively set nothing since the properties list was triggered but no properties were set to be used. I changed the code to check for a length before using the passed properties list.
Oddly enough, I don't have commit rights yet :(
====================Patch======================
<cfcomponent output="false"
hint="I am an Adapter implementation providing a wrapper around a CollectionBeanMaker? instance.">
<cffunction name="init" output="false">
<cfargument name="beanMaker" required="true" default="#createObject("component", "ModelGlue?.Util.CollectionBeanMaker?").init()#" hint="CollectionBeanMaker? instance to wrap." />
<cfset variables._bu = arguments.beanMaker />
<cfreturn this />
</cffunction>
<cffunction name="populate" output="false">
<cfargument name="target" type="any" hint="Either an instance of a CFC or the name of a CFC (e.g., ""com.mydomain.mymodel.MyBean?"") to populate." /> <cfargument name="source" type="any" hint="A structure to use as source for population." /> <cfargument name="properties" type="string" default="" hint="List to populate." /> <!--- Create instance if simple target ---> <cfif not isStruct(arguments.target)>
<cfset arguments.target = createObject("component", arguments.target) /> <cfif structKeyExists(arguments.target, "init")>
<cfinvoke component="#arguments.target#" method="init" />
</cfif>
</cfif>
<!--- Populate ---> <cfif len( trim( arguments.properties ) ) >
<cfset variables._bu.makeBean(arguments.source, arguments.target, arguments.properties) />
<cfelse>
<cfset variables._bu.makeBean(arguments.source, arguments.target) />
</cfif>
<cfreturn arguments.target />
</cffunction>
</cfcomponent>
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)