AJAX - A battle between Spry and CF8 built in facilities

I have been working on a new project which requires AJAX functionality and unlike some projects have some more time available to try out alternate ideas. The result has been interesting, so I thought I would share it.

There are a number of pieces of funcionality planned and in almost every case there has been a choice of using a CF function or a Spry equivalent and I have come down in favour of the Spry equivalent.

[More]

Setting a Select Control from a spry dataset.

I have been playing with Adobe's Spry AJAX framework and am most impressed by the Spry Dataset. It really gives Spry a big plus over some of the other frameworks since it makes handling data from databases much easier.

One thing that I needed was missing, an easy way to set a select control based on the dataset. It wan't however very difficult to do that when I tried. To save you wading though the docs to find it here is how I managed it.

[More]

New Books from Peachpit and new sitepoint Blog about CF

I had a note yesterday from Jackie Hill of Peachpit with details of a some new books that they are releasing this month.

Ben Forta's bestselling ColdFusion book has been updated for version 8, Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started. May well be of interest to my readers. I checked on Amazon and they also have Volume 2 and Volume 3 of the book affectionately known as CFWACK. I have posted links to all three volumes in the right hand menu bar.

With so much new stuff in CF8, Ben has had to split the book into three volumes. The pricing is also interesting since Volume 1 is way less than the other two. Maybe Adobe are getting the point that there needs to be a better path into CF for beginners.

On publicising CF. I see that Kay Smoljak is going to be blogging about ColdFusion at SitePoint. They regularly feature interesting articles about web site development and I often read with interest the articles on Javascript, AJAX, Search Engine Optimisation and CSS issues.

CFUnited - Advanced AJAX Development - Rakshith N

I went to another CF8 session with Rakshith N who was covering some of the new AJAX features.

CF8 now has an easy way to handle JSON. JSON is Javascript Object Notation and represents the data in Javascript. Based on array and object literals. It is less heavy than XML.

{ books:[
{isbn:'00230', title:'xyz'}
{isbn:'00231', title:'abc'}
}

CF8 has new functions to deal with JSON

  • SerializeJSON()
  • DeserializeJSON()
  • IsJSON()

When CF8 creates the JS data types, simple types remain as simple types, Arrays and Structs get converted to JS arrays and JS Structs.

There are two different formats of Query, Row format and Column format.

AJAX Plumbing

Essentially when we use AJAX some area of the page will be updated by a call to the server from a Javascript program. There is some HTML markup for the area of the page we want to update. We can now define an AJAX region with a cfdiv tag. cfdiv uses the bind parameter to link to a cfc or cfm page that will be called to create the content for that area of the page.

<cfdiv bind ="url:foo.cfm">
OR
<cfdiv bind ="cfc:bookData.getBookDetails({bookForm.isbn.value@change})">

There are four types of bind

  • CFC
  • Javascript
  • URL
  • Plain

A new cfajaxproxy tag will create a JS proxy for a cfc method, allowing you to call the cfc from within javascript.

A ColdFusion object in the client JS code can be used to get information from ColdFusion. For example you can use "ColdFusion.navigate" on a link to make it download a JSON object from the server.

Other examples:

ColdFusion.Ajax.submitForm(fomnId, url, callBasckHandler, errorHandler, httpMethod, asynch)

ColdFusion.log.dump(message.component)

In addition there are now AJAX versions of the tree and grid controls which can replace the Java versions in earlier CF.

<cftree name="mail" format="html" completepath="true">

There are tags to do layout like the flash form layout tags.

<cflayout type="border">

<cflayoutarea >

FlexManiacs - Day 2 - Mike Sundermeyer and Tom Hobbs - Adobe Experience Design

The XD Team is working with companies who want to push the envelope. Including RIAs and Mobile phone interfaces in Flash and Flex. Now working on new Flex components.

Mike and Tom outlined a typical scenario involving the development of page wireframes, then graphic design, then code in Flex or HTML. They then showed a series of new techniques and thinking that would allow much better user interfaces to be developed.

[More]

Scorpio News

There were a few already known facts about the new version of ColdFusion, known as Scorpio. As the tour of user groups to promote the new version progresses we are beginning to see some interesting postings on various Blogs.

The first one I noticed was Dave Shuck's Blog which has a really comprehensive list of the new features.

Dave reports on the capability of the new <cfimage> tag which I personally asked for in CF6 and CF7 but was disappointed. I don't expect to be disappointed this time as the tag seems to do everything I want.

I was also concerned by the lack of  an upgrade for the KTML edit facility in the new Adobe Dreamweaver Developer Toolbox extensions which have replaced the Interakt Tools, which we made good use of. I need not have worried as a better and easier solution has bee provided by the new RICHTEXT="true" attribute on the <cfinput> tag.

Two new tags have been designed to allow easier construction of portal type sites. <cfpod> and <cfwindow> can be used to create panels that can be resized and moved around. Dynamic menus are also supported by the <cfmenu> tag.

If you want to read a file <cfloop> will now loop over a file.

The small number of architecture gurus will be happy by the introduction of the <cfinterface> tag which allows ColdFusion to implement object oriented interfaces.

To pass arguments to tags argumentsCollection can be used in most cases avoiding some need to create strange logic when different numbers of parameters are present.

Integration with other Adobe products is a major benefit in the new version. Adobe Acrobat Connect users will be pleased to see that presentations can be created easily with the new <cfpresentation>, <cfpresenter> and <cfpresentationslide> tags, while <cfpdf> allows access to the metadata within a pdf file, merge pdf files, generate thumbnails, and encrypt pdfs.

The facilities with pdf files are also enhanced to allow forms to be completed offline and submitted to CF8 for processing by use of the <cfpdfform> tag.

As far as the cold fusion engine is concerned there is now much better support for performance tuning, with real time monitoring and the ability to take snapshots of the server at points when problems occur. Its also possible to run CF8 in a virtual machine under VMware.

On Ben Forta's Blog Ben has added more snippets with the news of support for JSON in AJAX. Two new functions, SerializeJSON() and DeserializeJSON() make it easy to convert data to and from JSON which is generally regarded as the best way to move data to and from AJAX applications. In addition, CFC methods can now return data serialized as JSON by specifying returnformat="json".

Ben also tells us about another new tag <cffeed> which can be used to read and create RSS or Atom syndication feeds.

Regular Expressions get two new function too with the introduction of REMatch() and REMatchNoCase().

There are new security features in Scorpio, giving increased control and flexibility in managing ColdFusion Administrator Access and RDS access.

In his blog, Ray Camden reveals that CF 8 has a function that checks for the existence of an array element. There is no longer a need to use try/catch if you have arrays that potentially have null elements.

He also notes that there are new ways to create arrays and structs and that AJAX is going to be supported through a number of tags. For example <cfajaxproxy> will handle all the JavaScript plumbing to let you invoke any CFC method from JavaScript, and support for refreshing AJAX grid controls.

You can also create a Spry dataset in CF8.

Some people are worried by the new features and think they might be on the way out. But personally the <cfexcahnge> tag looks like it will make it possible to move into new areas of functionality, and Ian Smith has identified 9 ways for CF8 to rule web development.

The ColdFusion Muse has identified that Scorpio will support the standard set of operators we are used to seeing from other languages like "++" and "!=". He also says that <cfajaxproxy> allows you to instantiate CFCs from the client. This exposes the functionality of your CFC in your JavaScript.

Among the other good CF8 snippets I found in the blogs were:

  • getComponentMetaData - lets you get metadata by passing a path of a CFC.
  • <cfstoredproc> now supports caching
  • query caching now works even when using cfqueryparam
  • <cfftp> now supports sftp
  • cfc serialization for session replication
  • Flash form restrictions removed.
  • Apache Derby, a 100% Java database, will be supported.

I can't wait.....

Spry Datasets + Free Beer + Adobe CS3.

I have been using Adobe Spry for the last few weeks to present tables of data and alow the user to filter and sort the data on the page.

I must admit I'm really impressed by how easy it is to add these features to a page. Unfortunately I can't give you a link for what I have done because it's for an intranet application.

If you're interested, I will be speaking about it tomorrow eveing at the Thames Valley Cold Fusion User Group.

The meeting will also be linking up with the Launch of Creative Suite 3 from New York and some lucky person will win a copy of CS3 in the raffle. You do have to come along to be entered in the raffle.

Adobe have offered to pay for the Beer too! Please add a comment to the Blog if you are planning to come along. That way I'll know how much Beer to buy.

What more could you ask for?

4:15pm Joe Rinehart - Make AJAX Easy with Model-Glue

Joe gave a good Intro to Ajax Technology and began by pointing out that most people don't use XML to transfer data from server to client, but use JSON or HTML instead.

The XMLHttpRequest object is used to make the request to the server. Many frameworks can be used to hide the complexity of these calls.

Joe likes the Prototype framework which is very simple to use. A single call can say get this URL and stick the results in a div tag.

For the example application he also used script.aculo.us, an extension to prototype, which provides some additional JS features.

He demonstrated how to create an event handler that deletes a record,
Include the AJAX and JS frame works,
Fade the deleted row,
You should also give some clues to the user that AJAX is being used.

Firebug was used to show the traffic between the Firefox browser and the server.

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