|By Charlie Arehart||
|August 23, 2002 12:00 AM EDT||
With each new release of CFMX some features are trumpeted a lot and others seem to fall between the cracks. I call these "hidden gems,"and in CFMX there are quite a few.
In this article I'll uncover several features that don't warrant publicity in the popular top 10 (or even top 20) lists that Macromedia and others might put out. Perhaps they won't influence the average IT buyer considering an upgrade. Sure, things like J2EE integration and XML/Web services support are critical to many organizations, and things like CFCs and Flash remoting may fundamentally change the way we develop CF apps.
But it's been my experience that what really intrigues most developers is the little things that have changed, some of which just may serve to make every day of our development lives easier without any substantial changes in current practices.
The big new things in CFMX are of course praiseworthy, and I don't mean to diminish them. It's just that maybe for some developers one or more of these hidden gems could be the real "gotta have" trigger that motivates them to upgrade. Or solve a long-standing problem.
I've broken the topics into a couple of categories. I'm not even mentioning all the hidden gems, nor even all the important changes to CFMX. As such, this article shouldn't be considered a compendium of all hidden gems. I can only highlight several.
Before proceeding, I want to point out that there are addititional new features of CFMX that may not get quite as much widespread acclaim. I don't consider them to be hidden gems since they're talked about often and are well documented. If you haven't yet looked into them, you should:
- CFFUNCTION: Creates UDFs that can include tags
- CFLOGIN, related tags: Support standardized login processing
- CFIMPORT: Enables JSP custom tags
- CFCHART: Replaces and exceeds CF5's CFGRAPH
- Automatic compilation of CF templates
- Support for internationalization (UNICODE)
- Improved debugging with CFTRACE
At the end of this article I'll point out several resources available for learning more about these and the other features I'll mention.
Hidden Gems in CFML
I've grouped the first set of hidden gems in a general category of CFML (ColdFusion Markup Language) gems, meaning new or changed tags and functions.
New Variable Scopes
More and more CF variable scopes have become available to use as structures. CFMX adds to this list the variables, caller, and server scopes. The value here is that you can use the CFLOOP COLLECTION tag to loop over the values in these scopes, or, more simply, you can display all the variables in a given scope with CFDUMP, among other things.
For instance, if you're not familiar with the server scope, try <CFDUMP VAR="#server#">. The output will show several useful variables you may never have known about, including several describing the CF server and the operating system it runs on. The server scope can also be written to, in which case any user on the entire server has shared access to the variables placed in that scope.
It's now possible to programmatically override the "request timeout" duration for a given template, using <CFSETTING REQUESTTIMEOUT="nn">, where "nn" is a number of seconds. The CF Administrator has a value set that controls the maximum time a CF template is allowed to run before the server "times out" the template. If you have a template that needs to run longer than that default, this is the means to programmatically indicate that it should be allowed to run longer.
Some will recognize this as an alternative to (and in some ways an improvement over) the long-existing means to make this sort of template-specific request to override the "request timeout" value. In previous releases you could add REQUESTTIMEOUT=nn to the query string of a URL requesting a template, and that indicated the maximum runtime for the template. That approach had its pluses and minuses, but it's important to note that this old query string approach is no longer supported (any value provided is ignored).
Try/catch in CFSCRIPT, UDFs
Prior to CFMX, there was no way to perform try/catch exception handling in the CFSCRIPT language (which was the means to create User-Defined Functions). This limitation has been lifted and there is now a Try and a Catch statement available in CF SCRIPT. See the documentation references provided later for more details.
Note: As opposed to CFML's CFTRY and CFCATCH tags, in CFSCRIPT, a Catch is not embedded within a Try. Also, while there are CFTHROW and CFRETHROW tags in CFML, there are no corresponding throw and rethrow statements in CFSCRIPT.
"Importing" CF Custom Tag Libraries, "Adaptive Tags"
In my article "Using JSP Custom Tags in CFMX" (CFDJ, Vol. 4, issue 5), I showed how you can use the new CFIMPORT tag to allow your applications to use JSP custom tags. One thing I didn't mention is that there's a side benefit to CFIMPORT, even if you're not using JSP custom tags. You can also use it to point to a directory that holds one or more CF custom tags (any directory with a relative path or using a mapped path in the CF Administrator). With that, you can then use JSP-style custom tag syntax to refer to your CF custom tags.
For instance, if you used <CFIMPORT TAGLIB="pathname" PREFIX="mytags"> to create a reference to some directory of tags that included sometag.cfm, you could now refer to it in your code with <mytags:sometag>.
There's also an interesting new possibility being referred to as "server-side HTML" or "adaptive tags." If you leave off the PREFIX in a CFIMPORT or set it to the empty string, then CF will process every tag (other than CF tags and taglib:-prefixed tags) as if it's a custom tag. It will look in the named TAGLIB to see if there's a template of that name, and will run it if there is. So if you had a page with such a CFIMPORT and had a file named form.cfm tag in such a taglib, a <form> tag on that page would cause CF to run form.cfm like a custom tag as it processed the page. Very interesting possibilities. Again, it cannot be used to override CF tags.
By the way, for those using CFIMPORT for JSP custom tags, I failed to mention in the article (available online at www.sys-con.com/coldfusion/article.cfm?id=435) that the feature of importing JSP custom tags is not supported in the Professional edition of CFMX. It's available only in Enterprise (or the Evaluation or Developer edition, which it becomes after 30 days of trial). I should clarify, however, that the notion of using CFIMPORT to work with CF custom tags does indeed work in all editions.
Evaluations Within Expressions
This hidden gem may not excite many, and it's actually a return to the way things were done in the past. You can now perform evaluations within expressions without needing to use the evaluate() function. For instance, if you wanted to display how long it took to run a query that was just executed, you couldn't (in CF5) just say:
<cfoutput>Time used:You'd need to use an evaluate around the expression cfquery.executiontime/1000. That's no longer needed. Removing it where it's not needed could yield a modest performance boost.
Miscellaneous Hidden Gems
Several other hidden gems that aren't part of CFML are worth pointing out.
CFMX Tag Updater for CF Studio
Folks who are still running CF Studio/HomeSite 4.5 or 5 will be thrilled to learn that they can arrange to install a "tag update" for the CFMX tags and functions. This way, the tag/function insight, tag editor, and tag/function help features work for most CFMX tags and functions (see www.macromedia.com/software/ coldfusionstudio/productinfo/resources/tag_updaters/). Also, there's an update for the Studio/HomeSite Help References (Help>Open Help References Window), available at http://download.macromedia.com/pub/homesite/ updates/cfml_ref.zip. Though the instructions in the zip suggest it works only for HomeSite + (part of the new Studio MX), the update also works in Studio/ HomeSite 4.5 or 5.
Free CFMX Hosting
If you're reluctant or unable to install CFMX, you may want to seek out a hosting company to do your testing. Fortunately, as of July, one company is offering free CFMX hosting for trial (nonproduction) purposes. See www.hostmysite.com/cfmx.hms for signup details. If anyone learns of other such instances, please let me know, or you can simply add them to the comments area of the online version of this article (see the end of this article for more on that).
Running CFMX on Mac OS X
Precompiling ColdFusionMX Templates
You may know that CFMX now compiles templates into Java classes. You may also have noticed that this means the first user to run a template after it's created or changed will suffer a small hit (up to a couple of seconds) when it's compiled the first time.
You can alleviate that wait by precompiling one or more templates. Unfortunately, the steps to do this take a little more room than we have for this article, so I'll save them for next month. There's also the matter of how to compile templates outside the default wwwroot directory (for those that have set up their servers to support that). In the meantime you can check out my blog at http://cfmxplus.blogspot.com/ for a preview of the topic.
Other Changes Worth Investigating
There are still more changes and/ or new features that I just don't have time to discuss. As mentioned in the next section, there are several resources from which you can learn more about these. Consider whether any of them may be of interest to you:
- Several Query of Query enhancements.
- Several CFLDAP changes.
- CFMAIL spooling option changes.
- Sort order in ListSort, ArraySort.
- Date processing functions have short, medium, long formats.
- Localization functions now follow Java standard rules.
- Several Regular Expressions support changes.
- CFTHROW can now throw an OBJECT.
- CFLOG now always writes thread, date, and time.
- CFHTTP reading text file in as query, new FIRSTROWASHEADERS attribute.
- COM object access improvements.
- Dynamic class reloading.
- New commenting flexibility.
- How to save the compiled template as .java (versus .class) files.
- Can indicate alternative directory for templates outside of normal <cfusionmx_home>\wwwroot.
- At least two Security Bulletins currently available.
- Many CF admin settings are now saved in <cfusion_home>\lib\neoruntime.xml.
- Examples in online CFML Reference are now housed at Macromedia.com (avoids security issues of running them locally).
There are still many others. You really owe it to yourself to read the resources mentioned next to make sure there aren't changes that could concern you.
Indeed, some of these issues fall more into the area of "hidden traps" for migration. I intentionally am not writing about those aspects of the upgrade. There are ample resources for that, not the least of which is the new manual, Migrating CF5 Applications, available within the substantial new CFMX documentation set. See the next section for how to obtain that both in print and online.
Finding More Information
The sources of many of the features I've mentioned here are the very documents that come with the new release. The thing is, many people don't know they exist or for some reason don't bother to or don't have the time to read them. I always point them out when possible, and it's especially important for this new release.
The entire CFMX documentation set has been revamped and added to. There are four updated and five new books. If you're not aware that there is documentation, or figure the books are just for reference, you really need to check them out. So many questions people ask are answered in the manuals.
The most substantial of them, Developing ColdFusion MX Applications with CFML, is a whopping 900 printed pages! No need to wait for books to hit the market: Macromedia has written one, and it's been improved over previous releases. Besides covering all the new features in a user-guide (rather than reference) style, it even has improved discussions of "old" subjects such as Query of Queries, UDFs, and CFSCRIPT.
You may find the manuals on your server at http://<yourserver>/cfdocs/dochome.htm. They're also available online at http://livedocs.macromedia.com/cfmxdocs/, and in PDF form at www.macromedia.com/support/coldfusion/documentation.html. Or you can buy them in print format (only $50 for the set) at http://dynamic.macromedia.com/bin/MM/store/US/ product.jsp?category=/BooksVideos/Documentation/ ColdFusionServer&type=FULL.
The books do indeed cover most of the new features, but there are always hidden gems in the "Release Notes" ( www.macromedia.com/support/coldfusion/ releasenotes/mx/releasenotes_mx.html), the "Documentations Updates" ( www.macromedia.com/v1/Handlers/ index.cfm?ID=22811&Method=Full), and the "Documentation Additions" ( www.macromedia.com/v1/Handlers/ index.cfm?id=22993&Method=Full).
There is also substantial coverage of new features on the Macromedia Designer/Developer site ( www.macromedia.com/desdev/mx/coldfusion/). And the "Upgrade FAQ" ( www.macromedia.com/software/coldfusion/ productinfo/faq/upgrade/) and "New Feature Comparison Grid" ( www.macromedia.com/software/coldfusion/ productinfo/upgrade/comparison.html) can also be useful.
Finally, don't miss the example applications that you'll likely find installed on your CFMX server, at http://<yourserver>/cfdocs/exampleapps/index.cfm.
There's a lot more to CFMX than it may seem at first. Indeed, I'd say "there's gold in them thar hills." Keep mining these resources for still more hidden gems, and feel free to add them to the online version of this article (whose link I'll offer on my list of articles at www.systemanage.com).
|dedi 05/04/03 12:42:00 AM EDT|
give me for mare information about available resources.
- Where Are RIA Technologies Headed in 2008?
- The Next Programming Models, RIAs and Composite Applications
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Constructing an Application with Flash Forms from the Ground Up
- Building a Zip Code Proximity Search with ColdFusion
- Personal Branding Checklist
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Has the Technology Bounceback Begun?
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- Adobe Flex 2: Advanced DataGrid
- Cloud People: A Who's Who of Cloud Computing
- Web Services Using ColdFusion and Apache CXF