Would this work?

<cfloop index="idx" from="1" to="#query.recordcount#">
#product.getItems().itemid[idx]#
</cfloop>

On 12/7/06, Aaron Roberson <[EMAIL PROTECTED]> wrote:
> I'm still working on my one-to-many object composition and I think
> I've found the solution but I don't know how to loop through the
> object in this instance.
>
> I have a product service with a getProduct() method. That method
> passes the product id to a item gateway which returns a query of
> product items with a matching product id. The query is then appended
> to the product object being returned by the getProduct() method in the
> product service. Here is some code to help make sense of it:
>
> <cffunction name="getproduct" access="public" output="false"
> returntype="whmedia.com.product.product">
>         <cfargument name="prodid" required="true" />
>         <cfscript>
>                 var vars = structNew();
>                 vars.product =
> createObject("component","whmedia.com.product.product").init(argumentCollection=arguments);
>                 variables.productDAO.read(vars.product);
>
>                 //set item query
>                 vars.items = 
> variables.itemgateway.getByAttributes(prodid=arguments.prodid);
>                 vars.product.setitems(vars.items);
>
>         </cfscript>
> <cfreturn vars.product>
> </cffunction>
>
> On my view page I can do a dump of the query contained within the
> product object like so:
> <cfdump vars="product.getItems()"/>
>
> I can also access each field in the items query using dot notation
> such as product.getItems().itemid
>
> What I can't figure out is how to loop through all of the records in
> the items query. I have tried <cfoutput query="product.getItems()">
> but it produces an error saying product.getItems() is invalid.
>
> As always, any help would be greatly appreciated!
>
> -Aaron
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263170
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to