Colony on Railo - Initial Testing Looks Good

Today we did initial testing of the Colony platform on the open source Railo 3.1 application server. I am pleased to share our findings that so far Colony runs without any issues on Railo. While we expect most customers that deploy CFML application to continue to use the award winning Adobe ColdFusion 9 Application Server, we are testing Colony on Railo in order to provide a fully free and open source distribution of the Colony application platform. 

IE 8 Ext bug- searchSortBy?

I just ran into a problem with an ExtJS application I am building that involves a bug in ExtJS for Internet Explorer, or perhaps a bug in IE itself. I created an Ext ComboBox with an ID of searchSortBy. When referencing the ComboBox by ID in a save function, I set a local variable:

   var ssb = Ext.getCmp("searchSortBy");

Which works just fine. But referencing:

   ssb.getValue();

yields an error of "Object does not support this property or method", meaning that the object being referenced is not the same as the object that I created. A simply ID change solved the problem, but it serves as a reminder of the continuing complexities of Javascript-basedWeb application UIs.

Bug in mysqld_safe wrapper

There is a bug in the latest release of mysqld_safe on Ubuntu that is causing cpu times to spike to 100% on the mysqld_safe wrapper. The bug has been documented on Launchpad, and a fix has been committed to the Jaunty (9.04) codebase, so it looks like the bug will be squashed soon. Still, this bug highlights the interconnected nature of software development and our reliance on the correct functionality of many significant components to modern server-based appplications.

 

PureMVC for Javascript

While working on a large-scale ExtJS-based Javascript UI, I became acutely aware of the limitations of the minimalist code architecture that dominated Javascript code development over the last several years. Accordingly, I was very pleased to see that there is a Javascript port of the PureMVC application framework in the works. It is in beta at the moment, but I will be looking at it in conjunction with ExtJS as the architectural basis of our Javascript-based application UIs moving forward.

ColdFusion Struct Key Names and JS/AS Code

If you use ColdFusion in conjunction with Javascript libraries like ExtJS or Actionscript in Flex or Flash, you are probably used to seeing ColdFusion structures rendered in JS/AS in ALLCAPS, like so:

 

CF code:
<cffunction name="getStruct" access="remote" returntype="struct">
     <cfset mystruct = structnew()/>
     <cfset mystruct.somekey = "somevalue"/>
     <cfreturn mystruct>
</cffunction>

JS result:
// a little pseudo-code
myObject = myService.getStruct();

//alert will show "somevalue"
alert(myObject.SOMEKEY);

By default, ColdFusion translates all struct keys into all caps when it returns a structure via a Web service or AMF call. If you would rather maintain your struct keys in lowercase or camelCase, you can simply use bracket notation instead of dot notation. Personally, I prefer dot notation for convenience, but sometimes I encounter a situation where dot notation would not work because the keyshave spaces or other characters that are illegal in ColdFusion variable names. As we can see with this example, there is another good reason to use bracket notation - case matching between client and server struct keys.

If we change our ColdFusion code to use bracket notation instead of dot notation, we'll get the keys in the case they were written:

CF code:
<cffunction name="getStruct" access="remote" returntype="struct">
     <cfset mystruct = structnew()/>
     <cfset mystruct["someKey"] = "somevalue"/>
     <cfreturn mystruct>
</cffunction>

JS result:
// a little pseudo-code
myObject = myService.getStruct();

//alert will show "somevalue"
alert(myObject.someKey);

 

Usability - Ugh, We Keep Making the Same Mistakes

Why isn't email address/name a top level, persistent email search feature for every mail client in exstence? If I am looking for an email in my mailbox, I generally am looking for a person by name or email address, a company by name or domain, or a particular topic.

Take Thunderbird, my current email client. I can quick search a subject or sender in any single folder, but if I want to search the entire mailbox, I have to pull up a special interface that leaves a lot to be desired from a usability perspective.

We keep making the same mistakes, in part because we keep building the same tools over and over again, trying to re-invent whatever application space we are designing for as we go.  One of the main reasons for us torelease the Colony application platform was to create the potential for large scale code re-use across a broad spectrum of typical web applications. 

Are you planning on building an application in CFML from scratch? Take a look at Colony and see if it might help you. A tutorial on using Colony is coming soon, stay tuned.

ExtJS Tree with Context Menu

I've been playing with the tree control in ExtJS, with an eye toward building a decent tree control to handle management of tree-based content, generally web pages in a basic web site layout. After some experimentation, I put together a tree that has a context menu and supports drag and drop of nodes. I am looking to extend it to enable drag and drop for external objects into the tree. 

Here is a screenshot, right click and select "View Image" to see a full size version:

click for full size image

Introducing the Colony application platform

For the past three years, I have been working on and off on an open-source CFML-based Web application. It  started out as a simple system to store arbitrary structured and unstructured content. I started using it to build more and more complex Web applications, and over time it grew in size and scope. I thought about it for awhile as a content management system, but content management is not what I was aiming for, and not where the platform has really evolved.

After struggling with terminology and purpose, I started thinking about the application as an application platform. What is that? I see it as an implementation of typical application patterns in an integrated package that allows a develoepr to use it in whole or in part, building on the core libraries to create a new solution. 

Once I had the concept clear in my head, I started casting about for a name. After lots of pondering and brainstorming sessions with my colleagues on the CF-Community list, I decided to call the platform Colony. To me, Colony is all about staking out new territory on the Web, building compelling new services, and advancing the state of software.

Colony is also about shared effort and shared reward. To that end, we have just released the platform in alpha under the Apache Software License 2.0. You can get the alpha code and see more about the platform at www.cfcolony.org. The site is graphically challenged and light on content at the moment, but that wil cahnge soon. 

Ext.History as a Controller for JS Applications

We have been implementing an ecommerce solution using the ExtJS framework, and one of the challenges our clients asked us to meet was to enable Back button support in the fully AJAX-enabled UI. After looking around at possible solutions, I decided to implement the Ext frameworks' Ext.History class as the history provider. Some example code at the Ext site gave me an idea - that it is possible to use the History class on() method to build a controller for a JS application that respects the Back button, allows bookmarking, and provides centralized application flow.

Here is my initial implementation:

     Ext.onReady( function() {
   
        //initialize the History provider
        Ext.History.init();
        //use forward slash for the delimiter
        var delim = '/';

        //set the on('change') event to act as the controller for browser history
        Ext.History.on('change', function(urlString){
            if(urlString){
                var arguments = urlString.split(delim);
                switch(arguments[0]){
                    case 'getPage':
                        getPage(arguments[1],arguments[2]);
                        break;
                    case 'doSearch':
                         doSearch(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]);
                    break;
                }

            }else{
                //reset the page
                setDefaults();
            }
        });


A typical call to a function that I want to track then changes from a direct call to the function to a call to Ext.History.add, so:

    getPage(#rootnode.objectid#,'webPage')

becomes

    Ext.History.add('getPage/#rootnode.objectid#/webPage');

and now I have a controller for the JS application. I may need to re-structure some code to make it neat and tidy, but I can now see the core of a well-structured solution taking shape.

Gotcha in ColdFusion 8 round() function

There is a gotcha in the ColdFusion round() function that you may not have seen. According to the ColdFusion docs, a value ending in .5 will always be rounded up to the nearest integer. However, ColdFusion has two ways of casting real numbers into underlying Java datatypes - double and float. It appears that when numbers are cast as double, they may not round up. Take a look at this sample code someone I know was having a problem with:

<cfscript>
  AmounttoTax = 30;
  CATaxExt = AmounttoTax * 0.0725;
  CATax = Round(CATaxExt * 100) / 100;
 </cfscript>
 <cfoutput>#CATax#<br></cfoutput>

According to the CF documentation, this code should yield a value of 2.18, because the original value of 217.5 (2.175 * 100) should be rounded up to 218. Instead, it rounds down to 217, and the resulting value is 2.17. 

Let's try changing the underlying datatype:

<cfscript>
  AmounttoTax = 30;
  CATaxExt = AmounttoTax * 0.0725;
  CATax = Round(javacast("float",CATaxExt * 100)) / 100;
</cfscript>
<cfoutput>#CATax#<br></cfoutput> 

This code yields the expected value of 2.18.

Just to be sure, let's cast the value explicitly into a double:

<cfscript>
  AmounttoTax = 30;
  CATaxExt = AmounttoTax * 0.0725;
  CATax = Round(javacast("double",CATaxExt * 100)) / 100;
</cfscript>
<cfoutput>#CATax#<br></cfoutput> 

Once again, we end up with a value of 2.17 instead of 2.18, leading (in the case of this code example) to a tax calculation that is one penny short of the correct withholding amount for the transaction. One penny may not be a lot in isolation, but over a large volume of transactions it may acculumulate into a non-trivial amount. 

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.