Posts Tagged ‘ColdFusion’

Missing cfdump styles on pages with certain types of DOCTYPE

Tuesday, December 11th, 2007

I’d had this problem for ages: during the development of a standards compliant site that includes a Doctype statement at the top of the XHTML code, it is not possible to comfortably use the cfdump function, a very nice tool for dumping variables that all CF developers are familiar with. All the styles are missing so instead of those nifty, colourful tables you are left with some bits of raw text on a white background that look quite ugly and are hard to work with. This issue occurs on ColdFusion and BlueDragon, probably because both engines use the same bit of CSS.

I came up with a simple solution to this problem: I just slightly modified the cfdump inline code making it a little more standards compliant and put it in an external CSS file. As a result, instead of this kind of layout:
cfdump screen grab when Doctype defined
…you get this:

cfdump screen grab when Doctype defined and the cfdump.css file included

The results are not exactly the same as the original ones, probably because of some CSS conflicts on this particular page, but I think it’s still worth trying.

The CSS file that repairs the styles can be downloaded below:

A patch for the CFML cfdump function run in an XHTML Doctype environment

Redirecting in CFscript - CFML cflocation equivalent

Wednesday, December 5th, 2007

In CFML you go:

<cflocation url="http://google.co.uk/">

with an additional “addtoken” attribute if needed.

Cflocation can be used both for external and local redirects, so you might as well want to have something like this:

<cflocation url="/section/page.cfm">

In cfscript there is no native equivalent function so you basically have two options. Either write a little wrapper UDF (using the CFML language) for the cflocation tag or take advantage of the GetPageContext function. If you want to replicate the cflocation behaviour in exactly the same way as it is in CFML, you can pick:

GetPageContext().getResponse().sendRedirect("LOCAL PATH OR URL");

AFAIK this hits the web server twice so for local redirections the forward method is a better solution:

GetPageContext().forward("LOCAL PATH");

The examples above have been tested on BlueDragon JX 7.0 on SUSE Linux.