I don't know how exactly to go about asking or even to look for this
really. How do you get a bean in a model? For example here is the code
I have. I know how to send it an instance of the object in the object,
just not sure how to in other methods of the same component.

<cffunction name="init" returntype="any">
        <cfargument name="datasource"
type="ModelGlue.Bean.CommonBeans.Datasource" required="true" />
        <cfargument name="layout" type="mv2.model.layout.layout"
required="true" />

        <cfset this.layout = arguments.layout />
        <cfset this.dsn = arguments.datasource.getDSN() />

        <cfreturn this />
</cffunction>

Then I was using duplicate on the layout object, but I read about it
being bad for performance so I would like to find the better way. Any
help?

Here is how I was using it:

<cffunction name="getAll_paged" returntype="array">
                <cfargument name="start" type="numeric" required="true" />
                <cfargument name="count" type="numeric" required="true" />
                <cfset var collection = [] />
                <cfset var obj = '' />
                <cfset var qry = '' />
                <cfset var end=0 />
                <!---- get all records from database ---->
                <cfquery name="qry" datasource="test">
                        SELECT id,productid,name FROM layouts
                </cfquery>
                <!---- load value objects ---->
                <cfif (arguments.start + arguments.count - 1) GTE 
qry.recordcount >
                        <cfset end = qry.recordcount />
                <cfelse>
                        <cfset end = arguments.start + arguments.count - 1 />
                </cfif>
                <cfloop from="#arguments.start#" to="#end#" index="i">
                        <cfset obj = duplicate(this.layout) />
                        <cfset obj.setId(qry.Id[i]) />
                        <cfset obj.setProductid(qry.Productid[i]) />
                        <cfset obj.setName(qry.Name[i]) />
                        <cfset arrayAppend(collection, obj) />
                </cfloop>
                <cfdump var="#collection#" abort>
                <cfabort>
                <!---- return success ---->
                <cfreturn collection />
        </cffunction>

Trying to wrap my brain around it all, and so far so good! Model glue
is really cool!

Thanks for any help!

Nathan Stanford II

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to