NO MORE CAREER
POLITICIANS!
Get Out Of Our House: Replacing congress with TRUE citizens!
Contact Doug!
Learn About Doug!
View Doug Boude's online resume
updated 11/18/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...
Web Hosting

best web hosting - top web hosting sites, thetop10bestwebhosting.com

Czech your Page Rank!
Check Page Rank of any web site pages instantly:
This free page rank checking tool is powered by Page Rank Checker service
Surf's Up!
Visit Egosurf.org and massage YOUR web ego!
My Score: 9,001
Doug's Books

Read (and recommend)

  • Men are from Mars, Women are from Venus
  • The Wisdom of Crowds: Why the Many Are Smarter Than the Few and How Collective Wisdom Shapes Business, Economies, Societies and Nations
  • Blink: The Power of Thinking Without Thinking
  • Head First Design Patterns
  • Transact-SQL Programming
  • What's So Amazing About Grace?
  • Just So Stories (Rudyard Kipling collection)

Reading

  • Prayer: Does it Make Any Difference?
  • Data Mining (Practical Machine Learning Tools and Techniques)
<< June, 2006 >>
SMTWTFS
123
45678910
11121314151617
18192021222324
252627282930
Search Blog

Recent Comments
Re: Railo 3.1 on Windows Server 2008 and IIS7 - Part 3 of 3 (by Jon at 8/27 2:04 PM)
Re: Hosts File Changes Not Acknowledged on Vista 64 (by Spacy at 8/24 3:46 PM)
Re: THE DAY CFUNITED DIED (by ComboFusion at 8/23 10:50 AM)
Re: My Grandpa (by Tasha at 8/10 4:29 PM)
Re: Just What IS a 'Service Layer', Anyway? (by dougboude at 8/02 10:10 AM)
Re: Just What IS a 'Service Layer', Anyway? (by Isaac at 8/02 2:25 AM)
Re: PayPal IPN Coldfusion CFC (by Soyestudiambre at 7/25 6:12 PM)
Re: PHP vs COLDFUSION (by Tony Garcia at 7/17 11:24 AM)
Re: PHP vs COLDFUSION (by dougboude at 7/14 8:45 AM)
Re: PHP vs COLDFUSION (by Lola LB at 7/14 5:51 AM)
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS

Powered by
BlogCFM v1.11

24 August 2006
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.



Posted by dougboude at 11:48 AM | PRINT THIS POST! |Link | 2 comments
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: When the Obvious is TOO Obvious: A lesson in Troubleshooting
Would using output="true" in you function make a difference in this instance?
Posted by doug s on September 20, 2006 at 9:18 AM

Re: When the Obvious is TOO Obvious: A lesson in Troubleshooting
I think you could consider this a bug to some degree. It seems a bit odd to me that applications settings would control output for components. What happens if you have a block-boxed component? I feel that it should have it's own settings.

Real world analogy:

You live in a house that has strict rules about adult content (ie. no magazines, no songs with bad lyrics, no adult televsion). But then you get a cable box with 600 channels. The televsion box doesn't automatically block adult content because it is contained within the house? No, it has to have a setting INSIDE of updated (ie. parental control).

Now, maybe that is a stetch of the imagination, to get that over to the world of ColdFusion, but it makes sense in my mind.
Posted by Ben Nadel on September 20, 2006 at 11:27 AM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

14 plus 13 equals
Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!