Railo 3 and Coldfish

Back in October I posted an entry mentioning that BlogCFC works with Railo 3.0. As it turns out it doesn't work 100%, or I should say the code highlighting part written by Jason Delmore doesn't work.

The Fix or Coldfish Railo-fied

As it turns out the problem wasn't too hard to fix. Apparently there are some slight differences in the way Coldfusion and Railo deal with underlying Java objects. When formatting the code Jason creates a java BufferedReader, and then


var reader = createObject("java","java.io.BufferedReader").init(IStream);
var line = reader.readLine();

He then passes the line (java object) to a format function and the line of code is then prettied up.

Here is where the trouble starts:


<cfscript>
            var character = "";
            var thisLine=arguments.line;
            var i =0;
            
            if (variables.isOneLineComment) endOneLineComment();
            
            for (i=0; i LT thisLine.length(); i=i+1)
            {
                character=thisLine.charAt(javacast('int',i));

                
                
                if (character EQ '
<')
/*a bunch more code*/
</cfscript>

The last line of code causes Railo to throw an error. The question is why? Well the problem it seems that the character variable is assigned a Java object and an object can not be compared to a simple string. Apparently CF automagically tags on the toString() function for you if you forget to. Railo isn't so forgiving.

By changing each instance of character to character.toString() the error went away and my code was beautified.

I tested the code change in CF8 and it works too. I don't have any younger versions of Coldfusion or Railo to test the changes on so it's probably better if you just upgrade :) I am including the CFC here if you want to download it for use with BlogCFC and Railo. Perhaps if someone has an older version of CF or Railo if they would like to test the code highlighting feature and let me know if it still works I would appreciate it.

Happy Coding...

3 Comments to "Railo 3 and Coldfish"- Add Yours
Chris's Gravatar Perfect! Thanks Gary!
# Posted By Chris | 11/11/08 11:05 AM
Gert Franz's Gravatar I stumbled across that error as well. Our new BlogCFC is running on the latest version. I am sorry, I should have told you. Anyway we will do the fix in one of the next patches so that Railo can compare a Java Char with a string as well.

Gert
# Posted By Gert Franz | 11/11/08 11:16 AM
Patrick Santora's Gravatar Very helpful! Thank you
# Posted By Patrick Santora | 1/28/09 4:39 PM

Powered By Railo

Subscribe

Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.

Tags

adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript jquery max2007 max2008 misc open source programming railo software technology ui

Recent Entries

No recent entries.

Blogroll

An Architect's View
CFSilence
Rey Bango
TalkingTree

Wish List

My Amazon.com Wish List