0

Five Cool Additions and One Undocumented Function in 8.0.1

ColdFusion 8

The release notes for ColdFusion 8.0.1 detail 10 pages of tweaks and new features. Here are five cool additions, and one undocumented function, in no particular order:

  • Leopard and 64 bit support
    Considering the devoted followers of both CF and Apple it was no surprise to see install solutions for CF8 popping up within hours of Leopards release. As cool as that is a supported release along with 64-bit support is extremely nice. And, wow, the speed of CF8 on Leopard 64 bit is impressive; re-inits take half the time they use to.
  • Nested Implicit Structure/Array
    Nested structures and arrays have always been possible. Now the implicit expressions work as well like so:
    <cfset variables.nestIt = {a=[{no="you did not",
           yes="I did",  
           oh=["and on",["and on"]]}]}>
  • cfwindow refreshOnShow attribute
    When using a source for cfwindow the default behavior is to cache the response for when the window is closed and then opened. I recently stumbled into this problem in an application I'm building. When refreshOnShow = true anytime the window is shown the content will be grabbed from the server.
  • Watermark with html
    cfpdf action="watermark" can now take html with formating in addition to an image. A nice, nice addition.
  • Richtext area for Safari
    Finally! WYSIWYG textarea support for Safari (3.0 and up) users. Big thanks should go to the FCKEditor team on this one since its their work along with Adobe's integration that makes it possible to do and have a rich textarea. I am especially happy with this as Safari is my current favorite browser (this can and does change often).

The other addition is an undocumented function: getPrinterList() that well, returns a list of printers that cfprint can print to.

(I will be presenting "Creating, Manipulating and Printing PDFs" and "Intro to CFML as a Language" at CFUnited in June.)

0

cfaui (Adobe User Intelligence) tags and functions up on Adobe Labs

ColdFusion 8

The most exciting feature of the ColdFusion 8 Updater 1 (now posted to Adobe Labs) is the new cfaui tags and functions. aui stands for Adobe User Intelligence and allows us CF developers to do a whole bunch of new cool stuff (rumors suggest a Flex version is on the way as well).

It is based on the technology in cfajaxproxy and the embedded Apache Derby database and can be added to any page by placing

<cfaui action="track" trackID="#session.userID">

anywhere on the page. This will track all actions a user takes on the page, store it in a database and constantly analyze it. The first cool usage is the action="hover" attribute which after a set period will display the text in any element defined on the page. Here's an example:

<cfaui action="hover" element="hoverTR" milliseconds="1000" 
messageElement="messageSpan" message="Most people pick chocolate" />

<tr id="hoverTR">
   <td>Favorite Ice Cream</td>
   <td><input type="text" name="favIceCrean">
    <span id="messageSpan"></span></td>
</tr>

What this does is after 1000 seconds of a user hovering over the the tr with the id of "hoverTR" it will place the content of the message attribute in the span with the id of "messageSpan".

One UI challenge I have always faced is whether to use a text box or select box for collecting a US state. Well with the new auiInputPreference function its now possible to give the user what they would prefer. Look at this example:

<cfif auiInputPreference(session.userID, "keyboard")>
  <input type="text" name="state">
<cfelse>
   <select name="state">....
</cfif>

The auiInputPreference function will always return a boolean. In this example I ask if the user has shown a preference for using the keyboard and if so will display a text box, if not (and in this case it would mean they lean towards using the mouse to move between fields) show a select box.

There are many other cool functions and features of the aui suite of tags and functions. Head over to the Adobe Labs and check out the documentation on the beta for ColdFusion 8 Updater 1.

+1

DerbyCFC: New Project with createIfNotExists function for Derby Databases

ColdFusion 8, DerbyCFC

I've just released version 0.9 of DerbyCFC on RIAForge which is designed to make it easier to work with the Derby database embedded in ColdFusion 8.

DerbyCFC comes with two functions; createIfNotExists which does pretty much what it says and will create a new Derby datasource and database. getDerbyDatasources returns all Derby datasources in either raw format (a collection of structures) or as a query with a slightly smaller set of attributes.

The download zip includes example pages for creating a datasource and listing of current datasources. Go to the DerbyCFC project page.

I'm debating whether to extend this to provide a UI that would list and edit tables in a Derby database so let me know your thoughts. My hope is that this will make it easier to create Derby databases for other open source projects.

0

cfdump output attrribute, The What, Why and How

ColdFusion 8

The What
Starting with ColdFusion 8 Adobe added a new attribute, output, to the incredibly popular cfdump tag. The default value is browser which works exactly how it has since the tags inception.

The Why
So, why use the output attribute? Mostly at a time when the request is not going back to the browser such as a scheduled task or when the data is going to an AJAX request or Flex. Or to log something -- the advantage of using cfdump output= over cflog is cfdump will parse whatever you throw at it into a text format.

The How
cfdump takes any cf variables or pretty much any type of object and returns the data. Here is the classic cfdump of a query

<cfquery datasource="cfartgallery" name="getArtists">
SELECT artistID, city, firstname, lastname, state 
FROM artists
WHERE state = 'DC'
</cfquery>

<cfdump var="#getArtists#">

produces



Place a filename in the output attribute and ColdFusion will dump the contents in a text format to that file. If the file does not exist, CF will create it, if it does exist CF will append to it.

<cfdump var="#getArtists#" output="/artists.txt">

Here is the output in artists.txt

Note the text format of data output, instead of just dumping the html that gets returned to the browser, cf provides a lighter format for the output files.

The third option is console which if you started CF from a command prompt will dump the output to the command prompt. If not CF will place the output in the cfserver.log file. To start CF from a command prompt from a multi-instance install open up terminal and cd to /Applications/JRun/bin and enter

./JRun -start cfusion
(Windows startup would be very similar). It is possible to start up the standard edition from the command line but there is little point to doing so as CF will still send the output to cfserver.log.

To send output to the console simply set output="console":

<cfdump var="#getArtists#" output="console">

produces this in Terminal:

Macs have a handy log viewer which works with any log file and automatically refreshes to show any changes. Here is the cfserver.log after running the above code on a Mac CF Standard Edition:

Overall the output attribute adds some useful capabilities to an extremely useful tag.

tags:
ColdFusion 8
0

Turn Long URLs in to Short Ones with ShortURL

ColdFusion 8, ShortURL

I have just released a new project on RIAForge called ShortURL that utilizes the onMissingTemplate function of ColdFusion 8. The full project description:

Short URL takes any URL then creates a random 6 character string and adds .cfm to it. When the link is clicked on onMissingTemplate receieves the URL, looks up the full URL and forwards the user to the full URL. Very similar to tinyURL and other services except this is hosted on your domain.

Jason Delmore suggested a while back that more ColdFusion open-source projects should have an install file. I have taken an attempt at this so install.cfm creates a database table and alters a setting in the Application.cfc file. After downloading the project, unzip it and run install.cfm.

This is a first release so if you find any problems let me know (we have been using this at Interfolio for 6 weeks with no problems).

tags:
ShortURL
0

How Interfolio Uses ColdFusion 8

ColdFusion 8

Sean Corfield recently blogged about some of the ways his company, Scazu, uses ColdFusion 8. I started to write a comment but it got long and morphed into this entry. At Interfolio, back in March, we received permission to build our revised product line on ColdFusion 8. I estimate that we saved at least a month of development time (4 to 3 months) due to this. We also won the Best of Scorpio contest as mentioned by Jason Delmore for which we won a PlayStation 3 (and has exposed how woefully bad I am at video games).

Here are some of the ways Interfolio uses ColdFusion 8:

Front End

  • cfajaxproxy -- use of cfajaxproxy has allowed us to write web interfaces that are dynamic based on a single proxy to a cfc. Both our delivery and add document pages have different sections that rely on each other for rules and data, and implementing this has been very straightforward. The serializeJSON function has allowed us to take a ColdFusion query and return it to the browser as JSON simply by passing the query to the function.
  • cfsprydataset -- use of the cfsprydataset tag and form bindings has allowed us to refresh a dataset based on criteria a user selects.
  • cfwindow -- we use this to collect survey data and provide quick updates in our admin section.
  • cfdiv and AjaxLink -- by placing a cfform inside a cfdiv the form is then submitted via AJAX and the returning html replaces the content of the cfdiv all without writing a line of JavaScript or reloading the page. With our new release we have implemented tagging to documents and persons. We have used the cfdiv and cfform tag to make this process as dynamic, interactive and responsive as possible to the user.
  • cfselect bindings -- we use this to simplify the classic two selects related functionality.
  • cfinput type=datefield and cfinput autosuggest -- the ease of adding a html calendar to a form and an autosuggest is staggering and has led to us using these features in places where we might not have spent the time in the past.

Processing

  • cffeed -- our company blog is hosted by Wordpress, we use cffeed to pull in the latest entries and display them in our product.
  • cfzip -- we use cfzip to combine multiple pdfs into one download.
  • cfpdf and cfpdfparam -- previously we used a third party tool to create a cover sheet and merge pdfs together. Now we use cfdocument to create the cover sheet and cfpdf with cfpdfparam to merge the pdf.
  • image functions -- we use several of the new image functions, in particular, to resize uploaded images.
  • cflocation statuscode -- our present application has many pages that we will not be using anymore. By using the new statuscode attribute of cflocation we can set permanently moved header information.
  • file functions -- for more efficient file operations we use the new file operations such as FileMove() and FileCopy().
  • Retrieval of auto generated identity keys -- previously we would have an extra query to obtain the value of the new ID, now we use the result structure and the generated_key key.

Language Enhancement

  • Application defined mappings and custom tag paths -- by defining mappings and custom tag paths inside an Application.cfc file has allowed us the ability to dynamically set these at runtime and drop and run our code with ease.
  • Implicit structure and array creation -- fewer lines and more readable code makes our development faster and cleaner.
  • onMissingMethod -- we have implemented a service layer for our application but, instead of writing a bunch of very similar functions that simply call a Gateway, we use onMissingMethod to call the gateway.
  • onMissingTemplate -- we create a "tinyurl" like short url for placing in emails. These links do not actually exist but are caught by onMissingTemplate which looks up the correct page and sends the user there. (I will be releasing this functionality in the next few days)

Server Monitor

  • We have an old computer running in our development room with server monitor up at all times for a real time view of the server. We have also used the slow requests and slow query features to tune our application.
tags:
ColdFusion 8

Search

Sam  Farmer