4 Replies Latest reply on Jun 3, 2009 7:55 PM by CFmonger

    cfobject / cfinvoke problem in my application.cfc

    CFmonger Level 1

      Hello;

      I am trying to use cfobject in my onsessionstart function in my application.cfc file. The cfobject is another application.cfc file I have in a sub directory in the web site, it runs the shopping cart. I am not firing this off properly and I was hoping someone could help me fix my code so it will operate properly.This is my invoke statement:

      <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
      <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">

       

      This is my whole argument statement for on session start:

       

      <cffunction name="onSessionStart" returntype="any" output="true">
      <cfset SESSION.created = now()> <!--- This sets off another session in the site --->
      <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
      <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">

      </cffunction>

       

      this is my error:

       

      Context validation error for tag cffunction.

      The end tag </cffunction> encountered on line 80 at column 11 requires a matching start tag.
      The error occurred in C:\website\Application.cfc: line 28
      26 : <cffunction name="onSessionStart" returntype="any" output="true">
      27 : <cfset SESSION.created = now()>
      28 : <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
      29 : <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">

       

       

      Can anyone help me? What do I need to do to set off my shopping cart functions on the cfc I am trying to invoke?

      Thank You

      CFmonger

        • 1. Re: cfobject / cfinvoke problem in my application.cfc
          Dan Bracuk Level 5

          This looks wrong because session.myShoppingCart is not a component, it's a variable.

          <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
          <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">

           

          Next, your cfinvoke does not have a returnvariable.

           

          None of this explains the missing start tag.  My guess is that it's a bonus error from your cfinvoke tag.

          • 2. Re: cfobject / cfinvoke problem in my application.cfc
            CFmonger Level 1

            this is what I am supposed to put in the on sessionstart function:

             

            <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">

             

            But this throws the same error. I am reading this off of instructions from a book. Obviously the book is wrong. Is there a way to make that cfobject statement work? I don't want a return variable. I want the ShoppingCart.cfc that resides in the sub directory /donation/ShoppingCart.cfc to go into client memory, I don't need a return value, I need the shoppong cart application portion fired when they hit the web site, creating a "shopping cart" in session / client variables.

             

            How would I do that using this tag? Thanks.

             

            CFmonger

            • 3. Re: cfobject / cfinvoke problem in my application.cfc
              Dan Bracuk Level 5

              Your cfobject tag is fine.  It's the cfinvoke that is probably messing you up.

               

              Once you have created an object from a cfc, you don't need to use the cfinvoke tag.  You call the methods like this.

              <cfobject name = "AnObject" component = "SomeComponent>

              <cfset SomeVariable = AnObject.AMethod(arguments go here)>

              • 4. Re: cfobject / cfinvoke problem in my application.cfc
                CFmonger Level 1

                That is what I am missing. The cfset tag.

                Would I write the cfset like this?

                <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">

                <cfset SESSION.myShoppingCart = ShoppingCart.get(arguments go here)>

                 

                 

                what argument would I give it and is get the method I want? actually, is this correct at all?

                 

                CFmonger