Aliaspooryorik
ColdFusion ORM Book

Simple debug view with FW/1

I've used ColdBox a lot for developing applications and it has a useful feature where you can view debugging output at the end of your page request. You can do a simple version of this in FW/1 by simply adding it to the onRequestEnd method of Application.cfc. In it's simplest form, this is all you need:

component extends="org.corfield.framework"
{
void function onRequestEnd()
{
if ( CGI.SERVER_NAME == 'localhost' )
{
WriteDump( var=rc, top=2, label="rc" );
WriteDump( var=request, top=2, label="request", expand="false" );
}
}
}

The first WriteDump call shows what is in the RC scope. The second is not really needed, but can be useful as it'll allow you to see the internal variables scope that FW/1 uses.

You need to be aware, that as the onRequestEnd method runs on every request (in 9.01 it even runs after an abort is called!), it will show for all subsystems (if any), but also for calls to views where you have set the request.layout flag to false. This means that any AJAX functionality may break. You can resolve this by checking for the request.layout flag before you render the debugging.

component extends="org.corfield.framework"
{
void function onRequestEnd()
{
var haslayout = !IsNull( request.layout ) ? request.layout : true;
if ( haslayout && CGI.SERVER_NAME == 'localhost' )
{
WriteDump( var=rc, top=2, label="rc" );
WriteDump( var=request, top=2, label="request", expand="false" );
}
}
}

The debugging could be improved, but as a quick and dirty way to see what's happening I find it useful and better than sticking a dump into a view or layout.


2 comments

  1. I do love the simplicity of FW/1. Nice tip!

    Comment by Andy Jarrett – August 03, 2011
  2. Nice, clean, simple. Good tip.

    Comment by John Allen – August 04, 2011

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments
 

Search

Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)

Categories

Recent Posts