About KCWebCore
KCWebCore(formerly KCMUG) is the new Adobe Users Group in Kansas City; managed by Dee Sadler. We are a community committed to skill enhancement, inspiration, and networking through the use of Adobe software and other Web-based technologies. We are the core of web design and development in the Kansas City area.

When the Obvious is TOO Obvious - A Lesson in Troubleshooting

Look at the following code and guess what the output would be:

<cfset strObj = createobject('component','com.makestring').init() />
<cfset newstring = strObj.getString() />
<cfoutput>#newstring#</cfoutput>

Oh, here's the cfc...

<CFCOMPONENT>
   <CFFUNCTION NAME="init" ACCESS="public" RETURNTYPE="makestring">
      <CFRETURN this>
   </CFFUNCTION>
   <CFFUNCTION
      NAME="getString"
      ACCESS="public"
      RETURNTYPE="string">

      <CFSET var thisString = "" />
      <CFSAVECONTENT
         VARIABLE="thisString">

         <ul>
            <li>list item 1</li>
            <li>list item 2</li>
            <li>list item 3</li>
         </ul>
      </CFSAVECONTENT>
      <CFRETURN thisString />
   </CFFUNCTION>
</CFCOMPONENT>

Choices:

  • A:[empty string]
  • B:
    • list item 1
    • list item 2
    • list item 3
  • C:depends

The correct answer is C, and what it depends on is whether or not somewhere else within your application a CFSETTING tag is lurking that has ENABLECFOUTPUTONLY set to 'Yes'. If this attribute is in effect, then your result will be A; if it's not, your result will be B.

The reason I felt the need to post on this is the fact that I spent a few hours yesterday developing a mild headache trying to figure out why my perfectly simple cfc was producing an empty string at one point within my app, but the correct string elsewhere. Through experimentation and noting that when I removed the CFSAVECONTENT tags everything worked as designed, I eventually concluded that I MUST have discovered a bug in the framework I was using, and so notified the keepers of the framework of all the details of my investigation and conclusion, along with code samples. They immediately (and nicely) informed me that more likely it was the fact that I had ENABLECFOUTPUTONLY enabled, and that I hadn't included CFOUTPUT tags within my CFC method. With egg still dripping from my face, I added the CFOUTPUT tags to my method and wouldn't ya know it...it worked.

I still haven't taken the time to find out where within this app the CFSETTING tag is being called, but two lessons gleaned here for me:

  1. Next time I feel excited at the prospect of having discovered a "bug", I'll think again (nobody wants the reputation of being The Boy Who Cried 'Bug!');
  2. Start troubleshooting from 10,000 feet instead of with a magnifying glass.

Comments
I too have had that problem a number of times. It makes debugging a real chore.

As a side note, you should also globally check your files for the <cfsilent> tag. It has a similar effect in that it hides the normal (non cfoutput) html.
# Posted By Ryan | 8/25/06 3:21 PM
Actually, the code as posted will throw an error. The calling code is calling "getString()", but there is no such method in the CFC. :-p
# Posted By Christopher Bradford | 8/25/06 3:56 PM
Get, Make, same difference. :P

Thanks for pointing that out Chris, I'll git 'er fixed.
# Posted By Doug Boude | 8/25/06 4:10 PM
<A href="http://www.vipwarhammergold.com/" target=_blank><FONT size=4><B>warhammer gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.vipwarhammergold.com/news/news.html" target="_blank">http://www.vipwarhammergold.com/news/news.html" target=_blank><FONT size=4><B>buy warhammer gold</B></FONT></A><BR><A href="http://www.bestwarhammer.com/" target=_blank><FONT size=4><B>warhammer gold</B></FONT></A><FONT size=4></FONT> <A href="http://www.bestwarhammer.com/news/news.html" target="_blank">http://www.bestwarhammer.com/news/news.html" target=_blank><FONT size=4><B>buy warhammer gold</B></FONT></A><BR><A href="http://www.aocsale.com/" target=_blank><FONT size=4><B>aoc gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.aocsale.com/aoc-news/" target="_blank">http://www.aocsale.com/aoc-news/" target=_blank><FONT size=4><B>age of conan gold</B></FONT></A><BR><A href="http://www.game4power.com/" target=_blank><FONT size=4><B>wow gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.game4power.com/news/" target="_blank">http://www.game4power.com/news/" target=_blank><FONT size=4><B>buy wow gold</B></FONT></A><BR><A href="http://www.wowgoldone.com/" target=_blank><FONT size=4><B>wow gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.wowgoldone.com/" target=_blank><FONT size=4><B>buy wow gold</B></FONT></A><BR><A href="http://www.game4power.com/" target=_blank><FONT size=4><B>world of warcraft gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.wowgoldone.com/" target=_blank><FONT size=4><B>world of warcraft gold</B></FONT></A><BR><A href="http://www.gamelevelup.com/" target=_blank><FONT size=4><B>wow power leveling</B></FONT></A><BR><A href="http://itemstores.com/" target=_blank><FONT size=4><B>wow item</B></FONT></A>
# Posted By warhammer gold | 11/10/08 3:37 AM
BlogCFC was created by Raymond Camden.  © Copyright 2006 KCWebCore. Some Rights Reserved.