> 1) so I'm calling the method wrong? or not invoking the component
> correctly?
Neither - you aren't calling the method on a CFC. You are trying to call it on a
struct. Hence the error. Dump out the 'objCart' variable, and I think you will find
what I mean.
> 2) >> A shopping cart should only manage the shopping cart. It
> shouldn't
> look at if it exists or not.
>
> yes good point but I was trying to tie the storage of cart data
> totally into
> the CFC. IMHO only the CFC should care how the cart data is stored
> and not
> be dependant on other files. The CFC becomes the data store
> interface. If
> the chosen storage doesn't exist, create it.
That is fine - however I would have built it like this:
<!--- component cart --->
<cfcomponent displayname="Cart">
<cfproperty name="aProducts" type="array">
<!--- contructor --->
<cfscript>
//place to store my carts
this.aProducts = ArrayNew(1);
</cfscript>
<cffunction name="AddToCart" access="public" output="false">
<cfargument name="key" required="true" type="numeric">
<cfargument name="value" required="true" type="numeric">
<!--- add the item --->
<cfscript>
StructInsert(this.aProducts, arguments.key,
arguments.value);
</cfscript>
</cffunction>
</cfcomponent>
<!--- application.cfm --->
<cfif NOT isDefined("session.cart")>
<cfscript>
session.cart = CreateObject(type, "com.Cart");
</cfscript>
</cfif>
- Hence all data is stored in the CFC - and is specific TO the CFC, and nothing
else (which gives lower coupling).
HTH
Mark
-----------------------------------
[EMAIL PROTECTED]
ICQ: 3094740
Safe From Bees
[www.safefrombees.com]
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MX Downunder AsiaPac DevCon - http://mxdu.com/