Copy link to clipboard
Copied
I have a report that is created within a CFLOOP over a list of integers. For each list element, a new report row is produced. Simple, and it works fine.
However, I'm having an intermittent display issue I can't figure out. Only periodically, for the same set of data, if I refresh the report screen I see the display of the last list element in the CFLOOP, e.g. "14" over the report on the screen. Hit refresh a few times it goes away. Some more refreshes and it comes back. At first I thought it was just a missed or unclosed CFOUTPUT, but no luck.
I've traced it so that it only displays that last list element in the CFLOOP. I created a smaller version of the code just for testing. Here is the CFLOOP statement: <cfloop list="10,14" index="ListItem"> Full code is at the bottom of this post.
Here is the output after several refreshes (this is correct).
Start loop for listitem:10
inner loop index=1
inner loop index=2
endloop
Start loop for listitem:14
inner loop index=1
inner loop index=2
endloop
And sometimes if I refresh, I get this output (note the 14, the last element in the CFLOOP list)
Start loop for listitem:10
inner loop index=1
inner loop index=2
endloop
Start loop for listitem:14
14 inner loop index=1
inner loop index=2
endloop
Again, that 14 only appears intermittenty. Inside my loop is a CFHTTP statement. If I comment out this statement, the '14' goes away, but obviously I need that statement. Just trying to track down the issue.
Here's my test code that produced the output above:
<cfloop list="10,14" index="ListItem">
Start loop for listitem:<cfoutput>#ListItem#</cfoutput> <br />
<cfobject component="#application.CFCPath#components.cGroup" name="clientObj">
<cfset ClientGroupInfo = clientObj.ServicePowerInfo(ListItem)>
<cfset ClientGroupDesc = clientObj.getClientGroupInfo(ListItem)>
<cfset ClientGroupCurrent = ClientGroupDesc.CompanyName>
<cfset form.runsheetdate = Now()>
<cfsavecontent variable="my_xml">
<dispatch>
<request>
<userID><cfoutput>#ClientGroupInfo["username"]#</cfoutput></userID>
<companyID><cfoutput>#ClientGroupInfo["companyid"]#</cfoutput></companyID>
<date><cfoutput>#DateFormat(form.runsheetdate,"YYYY-MM-DD")#</cfoutput></date>
</request>
</dispatch>
</cfsavecontent>
<cfset xml_obj = xmlparse(my_xml)>
<cfset webSvcURL = "http://test/test.aspx">
<cfhttp url="#webSvcURL#" charset="utf-8" method="post" ><cfhttpparam type="xml" value="#my_xml#"></cfhttp>
<cfloop index="i" from="1" to="2">
inner loop index=<cfoutput>#i#</cfoutput><br />
</cfloop>
endloop<br /><br />
</cfloop>
Any ideas are welcome!
I would say there's some situation under which one of those clientObj methods outputs the argument passes into it. Probably debugging code.
When troubleshooting these situations, I use the very non-technical method of putting a ABOVE and a BELOW in my code in locations which they output above and below the bit I'm trying to find. And slowly move them closer together in the code until one of them appears in the "wrong" place (eg: the ABOVE appears after the bit I'm trying to find. This is an ea
...Copy link to clipboard
Copied
I would say there's some situation under which one of those clientObj methods outputs the argument passes into it. Probably debugging code.
When troubleshooting these situations, I use the very non-technical method of putting a ABOVE and a BELOW in my code in locations which they output above and below the bit I'm trying to find. And slowly move them closer together in the code until one of them appears in the "wrong" place (eg: the ABOVE appears after the bit I'm trying to find. This is an easy way of isolating the line of code giving you grief.
Or course I could also use the debugger to do this, but I've been developing CF for sufficiently long with no debugger available that I forget to use it now that there is one available!
--
Adam
Copy link to clipboard
Copied
Thanks, that was a good idea. You were right; for some reason the CFC function was displaying the argument value intermittently. I'm not sure why, but I used the same query inline instead of from the CFC and the display is no longer there.
Any idea if that's a CF bug in general?
In any case, it works now. Thanks a bunch.
Copy link to clipboard
Copied
Any idea if that's a CF bug in general?
I would bet your life savings on it being a bug in your code. 😉
It's not a CF bug.
--
Adam
Copy link to clipboard
Copied
My first suggestion would be to track down the code that is outputting your variable in your component, but barring that you could look into the OUTPUT="no" attribute on <cffunction> which should prevent any content to be written to the screen from your component.