mudbuggle
asked on
Multiple Instances of a CFFunction/CFComponent
I am having an issue calling multiple instances of a cffunction. The problem is I intermittenly get null is null errors and some of the data is jumbled. The strange part is the issue is occurring with seperate functions as well. Any assistance would be greatly appreciated.
I have posted a simplified example of how I am calling the functions below.
I can post the actual code if needed.
I have posted a simplified example of how I am calling the functions below.
I can post the actual code if needed.
example:
<cfcomponent>
<cffunction name="getMenu" returntype="query" access="remote">
<cfaurgument name="menu" required="true">
<cfquery name="getmenu" datasource="someDB">
SELECT Title, id
FROM someTable
WHERE id = #menu#
</cfquery>
<cfreturn getmenu>
</cffunction>
</cfcomponent>
<html>
<head>
<script language="javascript" type="text/javascript">
function setMenu(obj)
{
var params = new Object();
params.Item = obj;
http('POST','url.cfc?method=getMenu',makeMenu,params);
}
function makeMenu(obj)
{
for(i=0;i<obj.id.length;i++)
{
var alter = document.getElementById(obj.id[i]);
alter.innerHTML = ob.title[i];
}
}
</script>
</head>
<body onload="setMenu(1);setMenu(2);setMenu(3);setMenu(4)">
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
<div id="4"></div>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Just an fyi... I won't be able to apply this until Sunday. From my understanding the cfqueryparam isn't needed when using arguments. The same security can be applied through the cfargument tag, or am I incorrect?
Also I scoped all of the variables for the calendar cffunction and it didn't help, the values it should have passed were still showing up incorrect. I since removed the scoping, because it didn't seem to make any difference.
This time I'll go through and scope my js as well as my cfm and see if that makes any difference. Thanks for all the help. I'll let you know Sunday.
Also I scoped all of the variables for the calendar cffunction and it didn't help, the values it should have passed were still showing up incorrect. I since removed the scoping, because it didn't seem to make any difference.
This time I'll go through and scope my js as well as my cfm and see if that makes any difference. Thanks for all the help. I'll let you know Sunday.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you for the fast and easy answers. I scoped all of the cfm and java that seems to have corrected the issue, apparently there where issues with the java as well. I'll have to keep that in mind from now on. Also duncan thank you for the excellent resources you posted. I have also made changes to all of my web apps to include cfqueryparam statement.
ASKER
For instance when I load the page sometimes all the menus on the left side load and other times one or two will not. The marqee doesn't have any issues at all, however the calendar application isn't loading the hidden input values correctly.
The strange part is any one of the applications/functions will run completely fine by themselves. For example when you change the month on the calendar all of the hidden input values load fine. I have also used the calendar for several other applications without any issues. Yet when I initially load the page and call all of the different applications/functions then I run into the null is null errors and the hidden input values comming up incorrectly.
Open in new window