Thursday, May 17, 2007

Some Notes from the D.C. Scorpio Presentation

(WARNING: Long post!)

I was at the Scorpio presentation in Washington D.C. last night. While the presentation didn't reveal any Scorpio features that haven't been covered in blog posts from earlier presentations (like here and here), I did pick up a few more details about certain things:

<cfajaxproxy>: As I mentioned in my last post, this tag will automatically created JavaScript code to call CFC methods via AJAX, like so:

<cfajaxproxy cfc="com.fooclass" jsclassname="cfFoo" />

<script language="javascript">
  var myFoo= new cfFoo();
  if (!myFoo.isEmailAddress(email))
  { alert("Please enter a valid e-mail address"); }

What I learned last night was that you can define a callback method for the calls to the CFC, so when data is returned asynchronously from the CFC, a particular JavaScript function will execute. It goes something like this (in JavaScript):


<cfdbinfo>: This feature was only mentioned recently. It's a tag that allows you to introspect any database ColdFusion can access via a datasource. You can retrieve the following information:

  • A list of the tables in the datasource
  • The version (of the database, I think)
  • A list of columns in the table (hopefully details about the column datatype, not mentioned)
  • The primary key, all foreign keys, and all indexed columns in a table
  • "Details" about stored procedures (whatever that means).

...I think this tag could drastically impact how ORM tools are developed.

<cfpresentation>, <cfpresentationslide>, and <cfpresenter>: When I first heard about the presentation and presentation slide tags, I envisioned that the result of using these tags would be a simple Flash slideshow, like the ones you see for viewing a series of pictures.

I was way off.

These tags generate a full-blown, full-window, Breeze-like presentation. In the example they showed us, the slides took up the left 2/3rds of the window. Below the slides were the usual slide controls (stop, start, pause, forward, backwards). On the right 1/3 of the window was a block of information about the presenter generated by the <cfpresenter> tag, which included a picture of the presenter, and below that were 3 tabbed columns providing access to other information (like notes and comments).

You can put pretty much anything within a <cfpresentationslide>: calls to external resources, movies, even operational Flex forms. The tag has a duration attribute that lets you set how many seconds the slide will display before moving to the next slide, and you can provide narration for the slide (narration is probably another attribute; they didn't use it in their example) via an MP3 file (they didn't say if other audio formats were supported). They also said that slide content was indexed, apparently to allow for searching.

You can define multiple presenters simply by using multiple <cfpresenter> blocks, and you can assign one presenter per slide by pointing the presenter attribute of the slide with the name of a <cfpresenter> block.

They pointed out two advantages to using these tags instead of simply uploading or converting a static presentation: the content of the slides can be updated dynamically (i.e. your sales chart could represent current data even if the presentation was built months ago), and you could use business logic to determine which slides a user could see.

Reaction options for an unresponsive server: I don't administer our CF Server (though I run my own locally), but I was interested in how the new alert functions in CF 8 could help my server admins, so I took in as much about that as I could.

They showed us the interface for configuring an Alert response to an "Unresponsive Server" (defined as a server that is exceeding its permitted thread count, I believe). There were several options for what the server should do if that condition arose, and I'm fairly certain you could choose all of them:

  • Send e-mail (there is another page tab where you define where that e-mail is sent to).
  • Dump snapshot (this will generate a text file containing a full statistical and status dump of the server in its present state for troubleshooting purposes).
  • Kill threads running longer than __ seconds.
  • Reject any new requests.
  • (Run) Processing CFC: ____. You can call a CFC you create. That CFC must contain two methods: onAlertStart() and onAlertEnd(). The page contained some guidance instructions on what you could do with those methods, but the text was a bit too small for me to read.

Other Alert conditions (besides Unresponsive Server) were Slow Server, JVM Memory, and Timeouts. They didn't really show those page tabs to us, so I don't know if the same response options are available for those (though I suspect they are).

onMissingMethod: You can now include this method in your CFCs to execute whenever something calls your CFC asking to run a function that doesn't exist. The onMissingMethod provides you with the name of the function that was called and the arguments that were passed in the call.

Obviously, it can be used as a means of error prevention/error handling, but it can be used for other purposes as well. Adam Lehman was running the demo part of the presentation, and he told us (and showed me later) an interesting use for it.

As tempted as I am to talk about it, I don't want to steal his thunder. I was hoping he had a blog and he written about it so I could just point folks to that, but if he has a blog I couldn't find it.

I will say this about it: it involves accommodating the erroneous request (think "controller").

Public beta: Maybe this was mentioned in someone's blog already and I missed it, and if I missed it then maybe others did as well. They said a public beta would be available: I believe the exact words Tim Buntel used were "very soon."

So keep an eye on Adobe Labs: I'm betting it'll be up there right after the Scorpio tour concludes (the start of June), if not sooner.

Wednesday, May 9, 2007

cfajaxproxy: No More Validation Duplication

ColdFusion 8 is going to include a huge new set of tools and features. How huge? Let's just say ColdFusion bloggers do not lack for material these days. And every few days another feature is revealed as Adobe folks tour the country with their preview demo.

It was recently revealed that ColdFusion 8 would contain a new tag called <cfajaxproxy> as part of a number of tags in support of AJAX functionality. Details are vague, but apparently the idea is that this tag lets you call the functions in a ColdFusion CFC file from JavaScript via an AJAX call and return the results of the functions back to the JS function.

That's a tremendously powerful tool. Most modern CF applications perform all of their business logic and database transactions through CFC functions, and now all of those algorithms can be made available via AJAX.

The area where this will really help is input validation. A good web developer knows that data input by a user should be validated before submission to the server by JavaScript, but that the server should also validate the data upon submission in case JavaScript is unavailable/turned off.

That used to mean maintaining two sets of validation functions: one in JS and one in ColdFusion.

Not anymore. Now you can write one set of validation routines in your CFC methods and use it for both client-side and server-side validation. A single set of routines, easy-to-maintain and, because they are written in ColdFusion and not JavaScript, browser-independent.

I can't wait!