> uses cfinvoke to call another cffunction in the same
cfcomponent.
Sorry, didn't see the reference to "the *same* component"
before. As per
Ian's comment, one ought not use the component attribute of
<cfinvoke> if
it's a local method. I just saw the code and ass-u-me'd.
But this leads me to spot another potential problem with your
code.
Although it'll not be what's causing your current problem;
it'll be a
problem if you take Ian's remedial action.
> <cfinvoke component="CFC.shoppingCart"
method="getCartProduct" returnvariable="getCartProduct">
More specifically:
> method="getCartProduct"
> returnvariable="getCartProduct"
A method within a CFC instance is just a variable (in the
variables scope).
The returnvariable of a cfinvoke call sets a variable. If one
doesn't
first VAR that variable, then it will be placed in the
variables scope.
In this case, your return variable will overwrite your
function variable,
and the function will be lost. You should not call your
variables the same
name as your functions: it will open you up to problems.
getCartProduct is
a good name for a function, because it describes what the
function does.
It's not a good name for the return variable, because the
return variables
doesn't *get* anything: it's the function that got the data
for you.
Now... this is all a bit irrelevant at the momennt because
your cfinvoke,
as it stands, should create a new instance of the CFC, run
the method,
return the value, and destroy the CFC instance (there's a
reasonable
overhead in doing all that, hence it not being a recommended
approach). So
you shouldn't be affecting any variable within the current
CFC instance
with that.
However if you every had this:
<cfinvoke method="getCartProduct"
returnvariable="getCartProduct">
Then the return variable would overwrite the same-named
function in the
current CFC instance.
Now... back to your reply to me.
> I can browse to
http://yoursite/CFC/shoppingCart.cfc,
but it shows an empty
page.
That seems odd. You should either get an RDS login screen or
the API docs
generated by CF when one browses to a CFC file. If you're not
getting
that, something is wrong.
> I do not have a CF mapping called CFC, pointing to the
dir that has shoppingCart.cfc in it, nor did I have on the old
server.
What about a custom tag mapping? That will also assist CF
finding wayward
CFCs.
> There are various other functions within the site that
use functions from this cfc without issue,
Are they all accessing it via the reference
"CFC.shoppingCart"?
I think if your CF template is in a directory which contains
a subdirectory
CFC with a file shoppingCart.cfc in it, then it'll work
without a mapping.
However because you're calling your CFC within itself,
clearly this is not
the case.
Other than that, you *need* a mapping - of some description -
so that CF
can locate the file.
Basically to reference a CFC via "CFC.shoppingCart", one of
these *must* be
true:
- CFC/shoppingCart.cfc is within the directory of the calling
template (be
that a CFM of a CFC);
- you have a web server mapping called "CFC", pointing to the
"CFC"
directory
- you have a CF mapping called "CFC", pointing to the "CFC"
directory
- you have a custom tag mapping pointing to a directory which
contains a
subdirectory called "CFC".
- there is a "CFC" subdirectory off the CF context root
directory.
You CFMX7 server config fulfilled at least one of those
situations; your
CF8 server does not.
That's your problem. I reckon.
--
Adam