TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

ColdFusion Blackstone Coolness

2 Comments

So I've been testing Macromedia's next version of Cold Fusion, named: Blackstone. I was writing a component, and used the self-doccumenting feature of cfc's to create a little documentation. However when I went to print it, it came out all crappy. For some reason these things never print right.

So I got to thinking wouldn't it be cool if you could output this documentation in flashpaper, since that's one of the features of Blackstone. Then I took a look at the url for the documentation, I noticed that the renderer for the cfc documentation was a cfc named "cfcexplorer.cfc," and the documentation was created using the "getcfcinhtml" mehtod. Since the cfc was installed on myserver I opend it up and saw this:

<cffunction name="getcfcinhtml" access="remote" hint="Generates html descriptor of a component with the specified name or URI path as the http response."> <cfargument name="name" type="string" required="yes" /> <cfargument name="path" type="string" required="no" /> <cftry> <cfscript> if ( IsDefined('arguments.path') and arguments.path neq '' ) { proxy = CreateObject( "java", "coldfusion.runtime.TemplateProxyFactory" ) ; comp = proxy.ResolvePath( arguments.path, getPageContext() ) ; } else { comp = CreateObject( "component", name ) ; } utils = CreateObject( "component", "utils" ) ; WriteOutput( utils.cfcToHTML(comp) ) ; </cfscript> <cfcatch type="coldfusion.runtime.CfJspPage$NoSuchTemplateException"> <cfoutput><h4>Component not found</h4> The component definition file for component '#name#' cannot be found on this server.</cfoutput> </cfcatch> </cftry> </cffunction>

So I got to thinking, couldn't I just wrap the whole thing in a <cfdocument> tag. I tried it, and it worked.

<cffunction name="getcfcinfp" access="remote" hint="Generates flashpaper descriptor of a component with the specified name or URI path as the http response."> <cfargument name="name" type="string" required="yes" /> <cfargument name="path" type="string" required="no" /> <cftry> <cfdocument format="flashpaper"> <cfscript> if ( IsDefined('arguments.path') and arguments.path neq '' ) { proxy = CreateObject( "java", "coldfusion.runtime.TemplateProxyFactory" ) ; comp = proxy.ResolvePath( arguments.path, getPageContext() ) ; } else { comp = CreateObject( "component", name ) ; } utils = CreateObject( "component", "utils" ) ; WriteOutput( utils.cfcToHTML(comp) ) ; </cfscript> </cfdocument> <cfcatch type="coldfusion.runtime.CfJspPage$NoSuchTemplateException"> <cfoutput><h4>Component not found</h4> The component definition file for component '#name#' cannot be found on this server.</cfoutput> </cfcatch> </cftry> </cffunction>

Once that's done, all you have to do is change the method called in the URL when you browse your cfc from "cfcexplorer.cfc?method=getcfcinhtml" to "cfcexplorer.cfc?method=getcfcinfp"

Cool huh? From the flashpaper, it prints beautifully.

2 responses so far ↓

  • 1 Steini Jonsson

    Just what I was looking for...

    Thanks,

    Steini
  • 2 Terrence Ryan

    Glad I could help. Although even though I came up with the thing in the first place, what would you actually use it for?

Leave a Comment









Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed html5 flash builder air mobile android driving technical change adobe apptacular running a coldfusion shop adobemax06 movable type flash catalyst flash css blackberry adobemax07 adobemax08 hero finicky adobemax09 holy crap i’m a mobile developer centaur phonegap basecamp cfc whichelement unfuddle motorola metablog irrational characters ios git evangelism edge devices code reviews ant wharton subversion security rhino philly philadelphia multidevice knowledge@wharton jobs javascript java browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile it github flexorg fireworks eclipse dreamweaver apps apple adobemax11