<rant>
I have to get this off my chest: the tag cfloop *REALLY* annoys me.
Not in all it's manifestations mind you, just in one of them, and that is... cfloop array. Why you might ask?
Well, if you want to loop an array you can do:
<cfloop array="#MyArray#" index="a">
<cfdump var="#a#">
</cfloop>
What "a" is in the index, is the actual item in the array. I think this is totally wrong to the point that if I had hair I would pull it out.
When the array attribute was introduced, I really think the developers had a brain fart.
They could have so easily used another attribute, maybe one that is already there. The attribute of "item" for example! I mean, it was there loitering in the tag lib, being used for collections, such as:
<cfloop array="#MyArray#" item="a">
<cfdump var="#a#">
</cfloop>
Now THAT makes sense! But why all the whining you might ask? Well, let's consider if you want to actually get the index of the array, what do you have to do? Oh yeah... set up another damn variable:
<cfset counter = 1>
<cfloop array="#MyArray#" index="a">
<cfdump var="#a#">
<cfset counter++>
</cfloop>
Wouldn't it have made a LOT more sense to do the following?:
<cfloop array="#MyArray#" item="a" index="counter">
<cfdump var="#a#"> The actual item
<cfdump var="#counter#"> The index of the item
</cfloop>
See? now "a" can be the *ITEM* in the array and "counter" can be the *index* of the array.
</rant>
Side rant: Why name it "collection" when we could have named it "struct"?
<cfloop struct="#myStruct#" item="st">
</cfloop>
Tags:
coldfusion · railo
Steve Bryant came up with the excellent idea of August 1st being designated How I Got Started In ColdFusion Day, for which ColdFusion users tell their origin story, So here goes mine!
Back in the mists of time, I had started a company called Creative Overload. We were mainly doing flat HTML websites, but specialised in VRML sites, and had done some interesting work for Brixton Academy and Virgin Radio at the time. Sadly, I saw myself as not experienced enough to be running such a company and left it in the capable hands of my then co-directors and left to find a new job somewhere else.
The job that I ended up taking was of Lead Web Developer at an ISP/Web Agency called NETTEC PLC. It was here (and over the many years I worked there) that I managed to work with many clients that were absolutely amazing. But I digress...
In the first few months that I was at Nettec Plc, we started working on a large Intershop site, the first CD's, Videos and games website in the UK with full transaction capabilities, and awesome side project of the Kingfisher Group, which at the time owned Wollies and other stores, but it was not for this project I used ColdFusion, it was actually an insurance company down the road that were looking to make choosing a policy much easier.
I don't recall from where it come, but I had a version of ColdFusion Studio installed on my machine and it had an awesome little wizzard attached to create a master detail page. And within a few hours and their database I had manged to do just that! I was amazed! I mean, I had been working with Perl so far and here was something that made sense, didn't need so many strange characters and just fit!
At Nettec we then did a lot of projects with ColdFusion, even being one of the main Allaire and then Macromedia partners in the UK, I even moved on to be a Spectra Specialist (for my sins) which I did all the way up to 2004/5
There you have it. How I got started with ColdFusion
Tags:
coldfusion

I got got confirmation from Packt Publishing that the RAW (read as it's written) version of the Railo for Beginners book has been released!
I have been writing this book for a while with the help of Gert Franz (Railo Technologies), Andrea Campolonghi and Paul Klinkenberg (Railo Volunteers). And of course a bunch of people that have been reviewing the book for me.
It's my first book so it has been a pretty long labour, especially since I publicly admit I coudl barely write an essay! But the prodding and cajoling by the editors to get me to finish each chapter has definately helped!
The book covers a lot of the aspects of Railo Server and I am hoping that by having this book out there more people will be interested in CFML and of course, Railo Server!
To quote the back cover:
Railo Server is one of the quickest ways to start developing complex web applications online. Widely considered as the fastest CFML (ColdFusion Markup Language) engine, Railo allows you to create dynamic web pages that can change depending on user input, database lookups, or even the time of day.
Railo 3 Beginner’s Guide will show you how to get up and running with Railo, as well as developing your web applications with the greatest of ease. You will learn how to install Railo and the basics of CFML to allow you to gradually build up your knowledge, and your dynamic web applications, as the book progresses.
Using Packt’s Beginner’s Guide approach, this book will guide you, with step-by-step instructions, through installing the Railo Server on various environments. You will learn how to use caches, resources, Event Gateways and special scripting functions that will allow you to create webpages with limitless functionality. You will even explore methods of extending Railo by adding your own tags to the server and building custom extensions.
Railo 3 Beginner’s Guide is a must for anyone getting to grips with Railo Server.
What you will learn from this book :
- Step-by-step instructions for developing web sites with CFML
- Learn about all the resource types available and how to handle them
- Easy to follow steps to optimise your application for high traffic
- Create dynamic applications with the in-built Hibernate ORM
- Secure your server by setting up access restrictions and passwords
- Convert and display multimedia within your webpages
- Create your own extensions for custom functionality
You can buy the eBook with all the currently published chapters as well as the full paper version when it's released from PacktPub Directly
Tags:
Book · railo
It has been my pleasure to be attending the WebDU Conference in Sydney this week. And what an awesome week it was!
WebDU is a great conference that has now been going on for about 9 years organised by the Daemon(ites) from Daemon Internet Consultants and I think it is THE Web Conference to go to on this side of the world.
[Read more →]
Tags:
CFConferences · couchdb · webdu
Having had an awesome time at WebDU, a couple of sessions had information about PhoneGap, JQuery Mobile and more importantly geolocation available in HTML 5 applications.
Some of the confusion arose from what the difference is between PhoneGap and JQuery Mobile provide.
Essentially, PhoneGap provides a common interface into the various API's provided on different movile devices. API's such as the Accelerometer, Camera, Compass, Geolocation, Contacts, Media and Notificaiton.
JQuery Mobile provides an API to develop a common UI that works across different devices as well as common ways for re-skinning and handling events within that UI.
A question come up about how to do GeoLocation within these devices and I pointed out that you can indeed do geolocation, and not only within a mobile device, but you can also do it using the HTML5 API's on desktop browsers.
This is actually really easy with the navigator.geolocation object in JavaScript.
To check whether you can actually use it all you have to do is check if this object exists in the DOM, with code like:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
}
Now, if you run this code from some function, you will need to pass in two functions that will recieve the current position, or throw an error if there has been some problem getting the current location. The expanded code is shown below:
function getLocation(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
document.getElementById("output").innerHTML = "Your browser doesn't handle the GeoLocation API. Use Safari, Firefox 4 or Chrome";
}
}
function success(loc){
strout = "";
for(l in loc.coords){
strout += l +" = " +loc.coords[l] + "<br>";
}
strout += '<img src="http://maps.google.com/maps/api/staticmap?center='+loc.coords.latitude+','+ loc.coords.longitude +'&zoom=15&size=400x400&sensor=false">';
document.getElementById("output").innerHTML = strout;
}
function error(err){
document.getElementById("output").innerHTML = err.message;
}
And that is it. No external libraries or PhoneGap API's. Just a standard browser call.
The navigator.geolocation.getCurrentPosotion() function will call the success(loc) function passing in a GeoPosition object that you can get the coordinates from. It also includes a few other handy properties such as longitude, lattitude, accuracy and heading if you are moving.
Check out a demo of the above code. There are no other libraries or includes so you can just view the source to see how it works.
Tags:
mobile
It has been two years today that I have been working at Railo Technologies and it gives me great pleasure to announce that Denny Valliant (@denstar) has just joined the team!
Denny is a great addition as he has been working with various packagers for Railo, and of course, he is the Lead Developer for the CFEclipse project!
How about that for a great combination eh?!
Welcome on board Denny! Hold on tight! It's gonna be a hell of a ride!
Check out the official announcement over that the
Railo Blog
Tags:
cfeclipse · getrailo · railo
March 31, 2011 ·
I am not sure people out there know this but Railo has four awesome functions that I use all the time, they are :
- getFunctionList
- getTagList
- getFunctionData
- getTagData
getFunctionList* and getTagList
These two functions will return a structure with all the functions or tags that are currently installed on the Railo server. For example, getFunctionList will return:
And getTagList will return:

getTagData and getFunctionData
Of course, this information in itself isn't amazing, since how do you know the arguments for each? This is where the getTagData and getFunctionData come in useful. For Example, if you want to get all the properties of say, the function ImageFilter (I created the FilterExplorer using this function), all you have to do is:
And you will get a nice struct with all the info:
The function getTagData is slightly different, in that you have to split out the namespace when calling it, so you have to call it as follows:
Which gets you all the attributes and documentation for the tag:
Simply using those tags, I have started a little project using CloudBees, ColdBox and of course Railo, that I shall show off a bit later.
* getFunctionList is also available in CF9
Tags:
getrailo · railo
A while ago I was playing with the Stax.net deployment system, since then they have been bought by CloudBees, a Platform as a Service for Java Web Apps and I wanted to see how easy it was to run Railo on it.
One of the advantages of running Railo in CloudBees (apart from scaling and versioning) is the ability to deploy incremental changes, rather than having to deploy the whole WAR as you have to do with AWS's BeanStalk. In this post I shall go through how to get a sample application running.
Requirements
Before we get started we need to do the following:
Once you have setup the CloudBees SDK as they have mentioned, you need to setup your API and Secret Keys, to do this you can go get your keys from your account page, and add them to the file that should have been created (if you are using OSX or a Linux OS ) in:
~/.bees/bees.conifg
Now that we have all that installed, let's go create a simple app through the CloudBees web interface, I have named my application "railo" (surprise, surprise!).
Once it has been created, click on the configure button so that you can get the ID of the application, in my case it is "markdrew/railo".
Now we have that application, we can go and download it, go to the folder you want to download the application to in the command line/terminal and type the following:
> mkdir markdrew_railo
> cd markdrew_railo
> bees getapp -a markdrew/railo
That was easy, if you setup your API and Secret keys you should get some XML and some other commands appearing and it should all be downloaded. Let's run it before adding Railo to the mix:
> bees run
After a few seconds you can head to
http://localhost:8080/ and get something that looks like the following:
Now to add Railo to our application. You can stop the application by pressing Ctrl + C, and then rename the railo-3.2.2.000.war to railo-3.2.2.000.zip and uncompress it:
> mv railo-3.2.2.000.war railo-3.2.2.000.zip
> unzip -d railo railo-3.2.2.000.zip
Now that we have unzipped the WAR file into the railo directory we can copy the contents from the railo/ directory to the markdrew_railo/webapp directory.
> cp -r railo/ markdrew_railo/webapp/
To test this, we can run the "bees run" command again and after a while you can test your application at http://localhost:8080/, you should get the Railo start page! Awesome!
Stop the application using Ctrl + C and let's clean out some files that are left over that we don't need:
> rm -r webapp/WEB-INF/classes/
> rm webapp/index.jsp
Now that we have cleaned it up and tested it , let's go ahead and deploy it. This is as simple as typing:
> bees deploy
The upload will take a while since it will upload something like 55Mb as our initial upload. Once this is done you should be able to check out your application live at the url defined in your configuration, mine is:
http://railo.markdrew.cloudbees.net/
Let's change the default homepage, so that we can see how much it has to upload next time. Change the contents of index.cfm to just display the current time:
<!DOCTYPE html>
<html>
<head>
<title>Changed!</title>
</head>
<body id="documentation" class="twoCol">
<cfoutput>
#Now()#
</cfoutput>
</body>
</html>
This time when we run the "bees deploy" command you should see that it has very quickly uploaded the changes and they should be live, without having to re-deploy the whole thing! Awesome! This is a massive advantage over AWS Beanstalk, that where small changes would require of a total re-deploy of your application.
Tags:
cloudbees · getrailo · railo
I have been doing a lot of JavaScript development recently and finally got my head round Ternary operations. Something that Railo Server has had for a while and I think was introduced to Adobe CF8 CF9 a while ago too. I just never got round to making it part of my standard coding practices, so I thought I would share.
If you have been doing this for a while, no need to point and laugh at me, but if you haven't, let me explain.
In your code you get to points where you have some code that looks like this:
<cfif MyVar EQ "something">
<cfset myResult = 1>
<cfelse>
<cfset myResult = 0>
</cfif>
When I see that, I tend to think, what is the fastest way to do this? What makes more sense? In the code above, in *theory* the variable myResult will always be created, but since it is always created, why have the cfelse statement?
I started coding in this manner subsequently:
<cfset myResult = 0>
<cfif MyVar EQ "something">
<cfset myResult = 1>
</cfif>
This way the myResult variable is always set to a "default" and only modified if the statement becomes true. For some reason this makes me feel happier and that the code is more robust (and of course, there is less of it).
With a ternary operation, you can even reduce ALL that code (omg! 4 lines of code!) into a single line:
<cfset myResult = MyVar EQ "something" ? 1 : 0>
The code above now is all in one line. The whole logic relating to the myResult variable is neatly encompassed in one line. Suddenly I feel so much happier.
Tags:
cfml · coldfusion · railo
One of the new functions that will be introduced in Railo 3.3 is the ImageFilter() function. This is one hell of a function with a LOT of parameters, so I thought rather than create some massive documentation index for it, I would make something a little but more fun; so introducing The Image Filter Explorer!
This small application allows you to explore the different filters you can use against an image, and see the result, along with a code sample of how to do that particular function.
You can check it out here: http://www.markdrew.co.uk/filterexplorer/
Tags:
railo