Setting up Mylyn in ColdFusion Builder 2

For a new project I have just started we are using the excellent Mylyn task focused system for Eclipse.

I have just spent a little bit of time working out exactly how to install Mylyn using the update system built into Eclipse and thus ColdFusion Builder 2.

To save other people this time, here is a quick guide to a base install:

 

Step 1: Go to the Help -> Add New Software link in ColdFusion Builder 2

 

Step 2: Type the Eclipse Helios update URL into the 'Work with' text field:

(This is the update site for Eclipse 3.6 which ColdFusion Builder 2 is built on)

... and click 'Add'. Give it a name (Helios Update Site for example) and click 'OK'

 

Step 3: Once the updates load (it may take a while) expand the 'Collaboration' item

 

Step 4: Select the following items - as shown in the screenshot:

 

Please Note: I have selected the 'Trac' connector as this is the system we are using on our current project. Obviously do not install this if you're not using Trac and select 'Bugzilla' if this is your bug tracker of choice.

Click 'Next' and then 'Finish' to install Mylyn.

Once complete you should click the button to restart ColdFusion Builder 2.

The Eclipse docs recommend starting with the -clean command line argument after installing new software which you can do like this:

 

C:\Program Files (x86)\Adobe\Adobe ColdFusion Builder 2 Beta\CFBuilder.exe" -clean

 

How I Got Started in ColdFusion

A couple of weeks ago Steve Bryant posted a blog entry with a great idea. This idea was that on 1st August 2011 all ColdFusion developers around the world should post on their blogs and tell the story of how they got into ColdFusion. As he points out on his blog post, these stories are often very interesting and not always what one might expect.

Now, I'm not sure my particular story is that interesting but I'll go a head and post it anyway. I've had a total blast working with this awesome web development system and would like to share how I discovered it.

The story begins in 1998 when I got my first job after graduating from university. It was with a small web development company who had recently lost their lead developer (to Netscape of all companies) and they needed a young graduate to take over. I got the role which was somewhat of a 'do everything' type position. My first 3 months goals were to pick up the HTML web development of the companies various clients and to learn the entire Microsoft server product suite that was in use on the internal company network.

The early days of the role were pretty much all HTML - often developing huge websites for fairly high profile clients and using Microsoft Frontpage 97. I can still recall the pain of copying pages and pages of product descriptions from technical order books, along with tricky HTML tables layouts for specifications etc. Back then, the only dynamic elements we would use were CGI e-mail handlers.

My first foray into web programming was actually not for the web. I was tasked with writing a log file analyser for Checkpoint Firewall 1. I hadn't used Perl before but it seemed like the obvious choice to use for building such a tool. It was quite a learning experience, to have deadlines to meet and a whole new language to learn but it was a great way to begin to get into more advanced development.

After that we would sometimes get asked for more dynamic elements for websites - a questionnaire for instance - and Perl was again the obvious choice, but was always quite a trial to get working exactly right.

So how does ColdFusion come into this then? Well, around 2000 / 2001 our company took on a new developer who was tasked with building a large e-commerce site. Before this the only e-commerce site we had built was via a product called Drumbeat (does anyone remember that?). It was truly awful. It built ASP websites using a visual editor and lots of code libraries but was a total pain to customise.. Not a nice experience.

Anyway, the new guy came to the company with some experience of a product called ColdFusion. He told us it was a really great way of developing websites and that he had picked up the basics very quickly and he came from a non-technical background. To speed up the development he looked around and found a product called CFWebstore which became the core of the first big e-commerce site the company had worked on.

This particular developer did not actually stay at the company very long and this project fell to me. It wasn't the best project to work on but was a good introduction to the awesomeness of ColdFusion 4.

The next developer to be taken on as a replacement had a lot more ColdFusion experience and came to the company with a number of development ideas which revolved around bespoke development - rather than off the shelf packages.

This was a real eye opener to me as he introduced the concept of custom CMS development using a MS Access DB (crazy to think we used that, though we moved onto SQL Server down the line). Sharing code meant that I was able to develop my knowledge as well as move in a personal direction in my own development. Due to the fact that we were in a small team and pretty much being given sole responsibility of each project meant that we both developed our own bespoke CMS systems, while sharing concepts with each other - always a great way to bounce ideas around.

It wasn't long before I was developing a huge range of sites ranging from basic CMS systems all the way up to enterprise Intranets and e-commerce sites. Our company never focused on one particular niche so we had to have a codebase that could adapt to *any* project. Having a bespoke CMS that could be customised based on ever changing project needs was pivitol and ColdFusion made it so much easier than it could have been. I would sometimes be shocked just how flexible CF could be when having to quickly respond to customer requirement or change requests.

I worked at that company for almost 10 years and ColdFusion became a very faithful and reliable friend... As it continues to be every day..

XMLSearch - No Results Found / Empty Array Solution

Just a quick post while it's fresh on my mind as I'm sure this is going to crop up in the future as I don't often handle XML in Coldfusion.

Basically here is the scenario. You have an XML file which isn't that complicated in structure but whatever you do XMLSearch just won't return the results you expect - it appears broken.

Here is an example from the Spotify API:

<?xml version="1.0" encoding="utf-8"?>
<artists xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">     
     <opensearch:Query role="request" startPage="1" searchTerms="Ash"/>
     <opensearch:totalResults>95</opensearch:totalResults>
     <opensearch:startIndex>0</opensearch:startIndex>
     <opensearch:itemsPerPage>100</opensearch:itemsPerPage>

     <artist href="spotify:artist:2evydP72Z45DouM4uMGsIE">     
          <name>Ash</name>
          <popularity>0.72515</popularity>
     </artist>

     <artist href="spotify:artist:77zwstbi3x1IxnbDFg6uns">
          <name>Wishbone Ash</name>
          <popularity>0.67812</popularity>
     </artist>
</artists>

Ok, in the above let's say I wan't to get all artists from the XML using xmlSearch.

The usual way would be to specify the following:

<cfset xml = xmlParse(xmlString)>

<cfset artists = xmlSearch(xml,"/artists/artist")>

This *should* work fine - top level 'artist' node, followed by some 'opensearch' and 'artist' nodes. We should now have an array of artist nodes in our artists variable. But we don't. Why?

Well the simple answer is, look closely at the artist node. Notice the xmlns attributes? They define an XML namespace and throw the whole thing out of whack. Ok, it's part of the spec but to get around this with XMLSearch we need to change our call to the following:

<cfset artists = XMLSearch(xml,"/:artists/:artist")>

Simple change but this tells the command to ignore the namespace and just return all 'artist' nodes that sit underneath the 'artists' node.

A simple distinction but one that can save hours of hair tearing. :)

Spellify for Coldfusion V1.0 Released

Spellify is an awesome textarea spell checker which uses a smooth and effective Ajax based interface. It's written by Nikola Kocic and can be downloaded here: http://www.spellify.com/

I was immediately impressed by the look and feel of this project which uses the Google spelling API but was dissapointed to see that it only supported PHP and .NET.

Well, I couldn't have this so set to work on a Coldfusion version. As CF makes these kinds of thing simple, within 30 minutes I had knocked together a Coldfusion version of Spellify.php which makes the call to the Google API and returns the XML to the Spellify Javascript.

I haven't tested this massively but it's a simple piece of code and seems to work nicely so I thought I'd get it released so you can get integrating Spellify if you need a spellchecker for textareas on your site.

Let me know if you find any issues with it.

This *should* work with all versions of CF - at least back to CF6 anyway.

Download Spellify.cfm V1.0

Here are the instructions - taken from the included READ ME.txt:

======================================================================
Spellify - Spellify.cfm v1.0 (based on Spellify.php by Nikola Kocic - http://www.spellify.com/)
Copyright (c) 2009 James Allen. (jamesallen.name, www.jwadevelopments.com)

E-Mail: james@jamesallen.name
======================================================================

Spellify.cfm is a Coldfusion version of Spellify.php for use with the superb Spellify text area spellchecker.

INSTALLATION (the following is based on the default spellify.php install and using demo.html to test):

1. Download and unpack the Spellify PHP package: http://www.spellify.com/download.html

2. Place it somewhere in your webroot, e.g /wwwroot/spell/

3. Copy Spellify.cfm to the same location as Spellify.php in the Spellify sub-folder (e.g wwwroot/spell/spellify/spellify.cfm).

4. Edit 'spellify/src/spellify.js', line 47. Change:

var defUrl  = 'spellify/spellify.php';

to

var defUrl  = 'spellify/spellify.cfm';

That's it!

Spellify should now be working with Coldfusion. You will probably have to change the defURL when you implement the code on your site (e.g /functions/spellify/spellify.cfm etc).

CFAjaxProxy - setCallBackHandler is global - remember that

Just a quick gotcha that caught me out for hours while using CFAjaxProxy in a messaging application I'm currently building.

When using CFAjaxProxy in asyncronous mode and setting a callback handler (setCallBackHandler(function)), be aware that this then becomes the callback handler for ALL subsequent calls. This is very important when building a complex Ajax application.

Basically when the user sends a message, I set a callback handler which then dynamically reloads the lists of past messages in the thread without leaving the message page.

Outside of this I have a global 30 second poll function which also uses CJAjaxProxy to obtain various user data (to alert of new messages etc). What I couldnt understand was that every 30 seconds the message list on this page would reload all by itself.. Spooky.. I searched my code looking for a call to my reloadThreadMessage() function but couldn't find one, outside of the send message function..

After much head scratching and shouting I finally realised that what was happening is every 30 seconds when the global poll was run, the CFAjaxProxy call to get the global data was still using the callback handler that was set when I sent the earlier message!

To fix this I simply place a call to setSyncMode() before the global data call and this removes the callback handler routine.

Something to bear in mind if your seeing weirdness while making multiple CFAjaxProxy calls in asyncronous mode..

How to fix CFWINDOW so the contents of the window layer are not visible on page load

Right, well I've been having lots of fun playing with the new super-duper CFWINDOW tag in CF8. What this lovely tag does is it allows you to quickly create impressive lookng web 2.0 style windows. The coolest feature of the tag is the ability to set a window as 'modal'. This makes the window one of those where the background of the page is greyed out with only the window being usable.. Very neat for login panel's etc. I'm making extensive use of this technology on the big project I'm currently working on.

Anyway, I became aware of an annoying problem today where the actual contents of the CFWINDOW was appearing at the top of the page while it was loading. Once loading was complete the content would dissapear as the Ajax goodness kicked in to hide it.. Well obviously on a production site this is simply not workable - we can't have our vistors seeing ugly text at the top of the design only to watch it vanish when the page is fully rendered.

Well anyway after an inspired moment about 10 minutes ago I realised that the key was to make sure the generated <div>'s tags that CFWINDOW creates to hold the window contents are set to render off screen. The fix is the incredibly complex piece of CSS ( :) ) that you need to add to your stylesheet:

.yuiextdlg {
    position:absolute;
    left:-200px;
}

You may need to play with the left offset if your CFWINDOW dimensions are quite wide.

This works a treat and ensures that all your CFWINDOW pages are loaded properly.

CF8 and json for Ajax - remember the UPPERCASE rule

Just a quick CF8 gotcha that can cause annoying problems if you aren't aware of it.

Basically, if your doing any AJAX in CF8 and using the returnFormat="json" functionality to get a CFC (with access="remote") to return data to Javascript on the frontend, remember this:

ColdFusion internally represents structure key names using all-uppercase characters

So what this basically means is that no matter how you specify your structure data in Coldfusion (e.g params.userName = "james"), when it arrives on the frontend via Javascript you MUST use UPPERCASE variable names.

E.G alert(proxy.USERNAME);

Just something to watch out for as it can catch you out..

Bug in calling CFC's remotely via the URL when using application.cfc

I've just been playing with the incredible <cfajaxproxy> tag in CF8 and have come across what appears to be a bug in Coldfusion when using application.cfc and calling CFC's via the URL method.

The URL method allows you to call CFC's via a URL and access any method in the CFC which has access="remote" set. Coldfusion will take care of returning the data as WDDX encoded or in JSON if using Coldfusion 8.


Anyway, I was testing this earlier today and found that no matter what I did, when calling a method in a CFC using the URL method a blank page was returned. It was incredibly frustrating!

A quick trip to the excellent #coldfusion IRC channel on Dalnet gave me the answer though (thanks Hapex) - application.cfc.

Well more specifically the onRequest method in application.cfc! For some reason if this method is defined in the file, remote CFC calls will simply display a blank page.

The solution? Comment out onRequest if you aren't making use of it. If you are, simply create an application.cfm and place it in the folder with your remotely accessed CFC's.

I believe this has been submitted to Adobe as a bug.. Hopefully it'll get fixed in the next release.

© 2012 James Allen | Contact Me
This blog runs on the awesome power of BlogCFC - created by Raymond Camden. This blog is running version 5.9.