Welcome!

ColdFusion Authors: Yakov Fain, Maureen O'Gara, Nancy Y. Nee, Tad Anderson, Daniel Kaar

Related Topics: ColdFusion

ColdFusion: Article

Hidden Gems in CFMX

Hidden Gems in CFMX

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.

Not-So-Hidden Gems
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
There are others, but you get my point. There's a lot more to this new release than just the "top" few features that are so often discussed.

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.

CFSETTING REQUESTTIMEOUT
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:
#cfquery.executiontime/1000#
seconds</cfoutput>
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
(Nonproduction Basis)

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
One topic that seem to be generating a lot of buzz among some members of the community is the question of whether CFMX can run on Mac OS X. Regardless of whether and when Macromedia will support that configuration, there are people hot to make it work, and there are at least a couple of resources where you can learn more about these efforts. The first part of an article series by CFer Dick Applebaum is available on the O'Reilly site at www.oreillynet.com/lpt/a//javascript/ 2002/06/21/coldfusion_one.html.

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).
One more is the new GetPageContext function. As I mentioned in my June article, "New Possibility in CFMX: Server-Side Redirects" (Vol. 4, issue 6), one of the most compelling possibilities to come out of that is allowing redirection from one CF page to another (or to a JSP or servlet) without a client-side redirect (which is what CFLOCATION does). See that article, available online at www.sys-con.com/coldfusion/article.cfm?id=450, for more information.

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).

More Stories By Charlie Arehart

A veteran ColdFusion developer since 1997, Charlie Arehart is a long-time contributor to the community and a recognized Adobe Community Expert. He's a certified Advanced CF Developer and Instructor for CF 4/5/6/7 and served as tech editor of CFDJ until 2003. Now an independent contractor (carehart.org) living in Alpharetta, GA, Charlie provides high-level troubleshooting/tuning assistance and training/mentoring for CF teams. He helps run the Online ColdFusion Meetup (coldfusionmeetup.com, an online CF user group), is a contributor to the CF8 WACK books by Ben Forta, and is frequently invited to speak at developer conferences and user groups worldwide.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
dedi 05/04/03 12:42:00 AM EDT

give me for mare information about available resources.

@ThingsExpo Stories
Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
BSQUARE is a global leader of embedded software solutions. We enable smart connected systems at the device level and beyond that millions use every day and provide actionable data solutions for the growing Internet of Things (IoT) market. We empower our world-class customers with our products, services and solutions to achieve innovation and success. For more information, visit www.bsquare.com.
How do APIs and IoT relate? The answer is not as simple as merely adding an API on top of a dumb device, but rather about understanding the architectural patterns for implementing an IoT fabric. There are typically two or three trends: Exposing the device to a management framework Exposing that management framework to a business centric logic • Exposing that business layer and data to end users. This last trend is the IoT stack, which involves a new shift in the separation of what stuff happens, where data lives and where the interface lies. For instance, it’s a mix of architectural style...
SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
Connected devices are changing the way we go about our everyday life, from wearables to driverless cars, to smart grids and entire industries revolutionizing business opportunities through smart objects, capable of two-way communication. But what happens when objects are given an IP-address, and we rely on that connection, sometimes with our lives? How do we secure those vast data infrastructures and safe-keep the privacy of sensitive information? This session will outline how each and every connected device can uphold a core root of trust via a unique cryptographic signature – a “bir...
SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
SYS-CON Events announced today that SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.
SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
P2P RTC will impact the landscape of communications, shifting from traditional telephony style communications models to OTT (Over-The-Top) cloud assisted & PaaS (Platform as a Service) communication services. The P2P shift will impact many areas of our lives, from mobile communication, human interactive web services, RTC and telephony infrastructure, user federation, security and privacy implications, business costs, and scalability. In his session at Internet of @ThingsExpo, Robin Raymond, Chief Architect at Hookflash Inc., will walk through the shifting landscape of traditional telephone a...
WebRTC defines no default signaling protocol, causing fragmentation between WebRTC silos. SIP and XMPP provide possibilities, but come with considerable complexity and are not designed for use in a web environment. In his session at Internet of @ThingsExpo, Matthew Hodgson, technical co-founder of the Matrix.org, will discuss how Matrix is a new non-profit Open Source Project that defines both a new HTTP-based standard for VoIP & IM signaling and provides reference implementations.

SUNNYVALE, Calif., Oct. 20, 2014 /PRNewswire/ -- Spansion Inc. (NYSE: CODE), a global leader in embedded systems, today added 96 new products to the Spansion® FM4 Family of flexible microcontrollers (MCUs). Based on the ARM® Cortex®-M4F core, the new MCUs boast a 200 MHz operating frequency and support a diverse set of on-chip peripherals for enhanced human machine interfaces (HMIs) and machine-to-machine (M2M) communications. The rich set of periphera...

SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
The Internet of Things (IoT) is going to require a new way of thinking and of developing software for speed, security and innovation. This requires IT leaders to balance business as usual while anticipating for the next market and technology trends. Cloud provides the right IT asset portfolio to help today’s IT leaders manage the old and prepare for the new. Today the cloud conversation is evolving from private and public to hybrid. This session will provide use cases and insights to reinforce the value of the network in helping organizations to maximize their company’s cloud experience.
The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
Predicted by Gartner to add $1.9 trillion to the global economy by 2020, the Internet of Everything (IoE) is based on the idea that devices, systems and services will connect in simple, transparent ways, enabling seamless interactions among devices across brands and sectors. As this vision unfolds, it is clear that no single company can accomplish the level of interoperability required to support the horizontal aspects of the IoE. The AllSeen Alliance, announced in December 2013, was formed with the goal to advance IoE adoption and innovation in the connected home, healthcare, education, aut...
SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
The only place to be June 9-11 is Cloud Expo & @ThingsExpo 2015 East at the Javits Center in New York City. Join us there as delegates from all over the world come to listen to and engage with speakers & sponsors from the leading Cloud Computing, IoT & Big Data companies. Cloud Expo & @ThingsExpo are the leading events covering the booming market of Cloud Computing, IoT & Big Data for the enterprise. Speakers from all over the world will be hand-picked for their ability to explore the economic strategies that utility/cloud computing provides. Whether public, private, or in a hybrid form, clo...