You will be redirected in 30 seconds or close now.

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

Related Topics: ColdFusion

ColdFusion: Article

ColdFusion Everywhere PART 1

Create applications that run on the Web, from CD, or on the desktop

Think about the last time you bought a car. Did you walk around the vehicle, look under the hood and sit in the driver's seat to get a feel for it? You probably took it for a test-drive before making the final decision. If you're a developer producing the next "killer app," it's only reasonable for your customers to want to test-drive your application as well. Have you ever wanted to demo your application but thought...

  • It's too difficult to put together a general-purpose demo.
  • Even if you did publish a "live" demo site, it would be open to wrong-headed visitors entering offensive data, corrupting the demo for others.
  • If you don't allow data entry, you limit the effectiveness of the demo.
  • You could allow users to download your application (in some protected time-limited format), but they would need to install it and all the prerequisite programs (CFML server, database server, application server, Web server). They would also have to configure the application, populate the database, etc., etc., etc. This could take hours (or days).
  • This is a daunting proposition even for the technically capable - who are likely not the people you want to see your demo. (If potential customers had to put together a Lexus before taking it for a test drive, they'd buy a BMW...)
Ideally, potential customers can experiment with your application at the time and place they choose, using their own data - with no unnecessary activities to deter or distract them, and no need to have access to the Internet.

What if you could deliver your application into the hands of customers in a package they could just double-click and run?

Well, you can! With readily available building blocks you can put together a self-contained package that holds your application and everything needed to run it on any platform you support. Your application appears as an icon on the desktop. You double-click and run...that's it! Nothing gets in the way!

In this article we'll show you a way to package and deploy your CF applications that is different from anything you've done before - making your application available as a single download (zip) file, or burning it onto a CD or DVD. If your application doesn't need to write files or update a database, it can be run directly from the CD. The objective is to enable you to run your CF application everywhere (the Web, a desktop, or CD) - we call the concept "CFEverywhere."

Examples of CFEverywhere Applications

CF has been used (almost) exclusively to develop applications for Web (and intranet) sites. With CFEverywhere, you are no longer limited to the Web dynamic. You can take advantage of the power of CF to write desktop applications.

Let's look at some examples of how you can use CFEverywhere today with current CF products.

A Downloadable Trial Application
This is the scenario discussed earlier - you have a Web application that you want to give to potential customers to "try before you buy." Here customers run your Web application with full read/write database and file capabilities on their desktops.

A Web Site On a CD
A company maintains a Web site containing a catalog of thousands of items in hundreds of categories. To promote their site the company makes CDs of the entire site, which it hands out to potential customers at an annual trade show.

The Web site exists as a database-driven series of CF templates. Without CFEverywhere, it takes days of tedious, painstaking (and expensive) effort to convert the site to thousands of interlinked static HTML pages that can be accessed from a CD. Some Web site capabilities, such as searching and sorting, are not possible in the static version. With CFEverywhere, the Web site (CF templates and database) is copied intact to the CD along with the other components necessary to run CFEverywhere.

The time and expense of the conversion to static pages is eliminated. The user experience is enhanced because the CFEverywhere version contains all of the searching and sorting capabilities that exist on the Web site - in fact, we have duplicated the actual Web site onto the CD.

A Combination Offline/Online Application
There is a class of applications that can be used in a combination of ways. Some sections of the application do not require access to the Internet and run quite happily on the desktop using local files and data. Other sections require connection to the Web site and synchronization with the corporate database.

Consider this scenario: a manager updates a local copy of employee appraisals while off on retreat at a mountain cabin (with no access to the Internet). Later, upon returning to the real world, the manager connects to the corporate Web site and applies all the local updates to the corporate database.

There are many corporate activities that could follow the same pattern of offline data entry batched for online data update/cutover: price changes, new product catalogs, inventory counts, etc.

For example, a mail-order company with a large seasonal catalog sends a promotional CD to potential customers. Customers browse the catalog at their convenience selecting items to order: gift cards, shipping addresses, wrapping paper, etc. This is done over several days or weeks. The program is run directly from the CD, but the information is saved in a file on the customer's hard disk. When customers are ready to order, they click a button and the application connects to the vendor's Web site, uploads the order, and displays any "specials" not in the catalog. Truly, customers shop at their convenience - not governed by whether the Internet is available (or performing poorly because of traffic congestion).

Portfolio Piece
The Web is ever-changing. You may have written Web sites or applications that have been taken in-house and/or have been extended by other developers. Or, your implementation of the site was so dazzling that the company was purchased by another and for whatever reason, you can't point to these Web sites as examples of your work.

With CFEverywhere, you can maintain an archive of all the CF sites and applications you have developed, and create a "portfolio" CD for potential customers.

CF Desktop (non-Web) Applications
Traditionally, CF has been used to develop Web applications. However, many developers use CF as a quick, powerful solution for doing some non Web-related tasks such as reformatting and populating a database, statistical/design analysis of a database; application prototyping, and ad hoc report generation.

With CFEverywhere, you can actually develop applications specifically for the desktop. Use your imagination. Once you realize that you don't (necessarily) need a Web site to take advantage of the power of CF, a world of possibilities opens:

  • A CF application can be a low-cost alternative to writing a desktop application in Java or C. This is especially true when the programming resources are limited and there is a large backlog of high(er) priority applications. A CF solution could be implemented to provide immediate results (and benefits) until a more rigorous solution can be implemented in the other language.
  • Or, maybe the requirement is for a one-time report or analysis that is due yesterday - where CF is the only way to get it done. While a browser implementation of a user interface may not be ideal for a desktop application, it is likely to be easier and less expensive to implement than a custom UI written by other means. Arguably, the browser UI will be more familiar (and comfortable) for most users than a custom UI.
  • You could write a control panel/monitor that displays the status of all components of the system.
  • You can write desktop applications that invoke Web-related facilities (e-mail, messaging, Web services) to provide desktop functions.
    - For example, the control panel/monitor application could use e-mail to send an SMS text message to a technician's cellphone, alerting him that the system needs attention.
    - Or, a desktop application could invoke a Web service to obtain stock prices to update your portfolio.
    - Or, send an e-mail to a CF desktop application that reboots the database server. Since the CF application runs on the desktop, it can (with authentication) have complete access to the OS facilities, file system, scripting languages, etc.
For example, you could write a CF application that watches a certain folder in a user's system. Whenever an image file is added to the folder, the CF application executes a shell script to invoke Photoshop to copy and resize the image into a database or photo album (or product catalog).

These are only a few ideas of how CFEverywhere can deliver applications - on the desktop! Certainly, these are quite different from "typical" CF Web applications! Hopefully, we've whet your appetite for CFEverywhere. In the next section we will begin to assemble the CFEverywhere system to deliver your application.

CFEverywhere Components

To achieve CFEverywhere, the following components are required: a J2EE server, a Web server, a database server, a CFML runtime and, of course, our application code. The J2EE server acts as a "container" for the runtime that executes the application code. Let's go through the process of choosing the appropriate components and performing their configuration. In this section, we will configure and install the Web/J2EE servers and the CFML runtime. (Note: This process is cross-platform and works for Windows and Mac OS X/Linux.) Figure 1 shows the CFEverywhere directory structure.

There are several J2EE servers available on the market today. Some are open source while others are commercial offerings. You may have heard of these J2EE server products: JBoss AS, BEA WebLogic, and Macromedia JRun. For our purposes we will use a server called Jetty from Mort Bay Consulting. Jetty was selected for the following reasons:

  • It's free
  • It includes a Web server
  • The license allows for commercial use and distribution
  • It's easy to install and configure
  • It has a small footprint and is embeddable
We also need to select a CFML runtime. In addition to Macromedia CFMX/J2EE, there is a product called BlueDragon 6.1/J2EE from New Atlanta. Of these products, only BlueDragon can be used with CFEverywhere due to licensing restrictions. New Atlanta has a very friendly OEM/partner program that allows for distribution of BlueDragon with your CF application. Contact them and they'll be happy to discuss the details of their program. Macromedia currently has no such program but we understand the next release of CFMX (code name Blackstone) may address this issue and make it suitable for a CFEverywhere application. We'll have to wait and see.

Before we proceed further, make sure your system has a Java runtime installed. At a command prompt (or terminal on Mac OS X) type:

java -version

You should see something like "java version 1.4.2_05." If you get an error, you don't have Java installed/configured on your system. Go to http://java.sun.com/downloads/index.html to download the Java runtime. Note that although the latest version of Java is 1.5 (a k a 5.0) most products are not yet supported for that version. Your best bet is to install a Java runtime version 1.4.x. Also, create a folder for the project and call it "CFEverywhere." For example:

  • D:\CFEverywhere (for Windows)
  • /Applications/CFEverywhere (for Mac OS X)
Download Jetty from the Jetty Web site, http://jetty.mortbay.org. The latest stable version is 5.1.0 so you should download jetty-5.1.0-all.zip, which includes demo files and other extras. Extract the zip file into your CFEverywhere folder. It will expand as jetty-5.1.0, but to save some typing at the command line, rename the folder server. Create a new folder underneath the CFEverywhere/server directory called wwwroot. This folder will serve as the Web root for our CFML application. To test your Jetty installation, open a command line and change to the server directory

cd d:\CFEverywhere\server

Then start the server

java -jar start.jar etc/demo.xml

This will start Jetty; you can test it by pointing your Web browser to http://localhost:8080/. You should see a version of the Jetty Web site. If you don"t, you may have a port conflict with port 8080. Check for any other servers listening on that port and shut them down.

By launching the Jetty demo, you noticed that Jetty is configured with XML files. We need to create a configuration file for our CFEverywhere application. Copy the demo.xml to a file called CFEverywhere.xml. Open the file in any text editor and change the root context to point to the /CFEverywhere/server/wwwroot folder. It should look like the following:

  <!-- Add root context web applications. -->
  <Call name="addWebApplication">
    <Arg><SystemProperty name="jetty.home" default="."/>/wwwroot</Arg>
    <Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>

(The complete file can be downloaded from sys-con.com/coldfusion/sourcec.cfm). Let's create a couple of test pages. Create a simple index.html page that displays "Hello World" and put it in the wwwroot directory. Next, create a file CFEverywhere.cfm with this code:

<cfset message = "Hello World! -- CFEverywhere" />
<cfdump var=#cgi#>

Now launch Jetty with:

java -jar start.jar etc/CFEverywhere.xml

This time when you point your browser to http://localhost:8080/, you should see "Hello World." Great! We're able to serve up HTML files but we really want to run our CFML page. Enter BlueDragon...

Go to the New Atlanta Web site, www.newatlanta.com, and download the latest BlueDragon 6.1 for J2EE (BlueDragon_J2EE_61.zip). Extract the archive to a convenient location like your desktop but don't put it in the CFEverywhere folder. Copy the contents of the BlueDragon_webapp_61 folder to your CFEverywhere/server/wwwroot folder (just the contents, not the entire folder). I hope you didn't blink because you might have missed it. You just deployed BlueDragon/J2EE on Jetty! Now launch Jetty again like we did previously. Browse to http://localhost:8080/CFEverywhere.cfm and you should see "Hello World! -- CFEverywhere" as well as a dump of the CGI scope variables.

That's it! You've just completed your first CFEverywhere application. Try transferring the CFEverywhere files to another computer (even on a different platform) and see if you can get it to run. If the "Hello World! -- CFEverywhere" application doesn't inspire you, come back for the other articles in this series where we'll:

  • Show you how to deploy a typical CF application that includes a database
  • Make a clickable application that can run on Mac OS X and Windows
  • Burn it to CD-ROM

More Stories By Phil Cruz

Phil Cruz is a Macromedia Certified Advanced ColdFusion developer and has over 12 years of experience in the computing industry. He is responsible for www.mach-ii.info, a community site for the Mach-II framework. As a micro-ISV, he created Tracking Tools, an easy-to-use bug tracking application built with Mach-II (www.tracking-tools.com).

More Stories By Dick Applebaum

Dick Applebaum has been involved with computers (and their predecessors) since 1956, including 16 years with IBM. Dick and two partners opened the fifth retail computer store in Silicon Valley in 1978. Eleven years later, he sold the stores and didn?t touch a computer for seven years (when he discovered the Web). Since 1997, Dick has been developing applications using ColdFusion.

Comments (4) 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
giuseppe 02/19/08 05:40:54 AM EST

I read your CFEverywhere part 1, 2 and 3:
very interesting ! ! !
Do you know something more about Macromedia license program for distribute CF Desktop applications?

Otoniel Rojas 02/07/05 10:54:53 AM EST

This is great!!! It works perfectly. I am eagerly waiting for the rest!!.

Eli Sanders 02/02/05 12:09:23 PM EST

Great Article... can't wait for next edition... everything worked just as they said...

pim 01/27/05 03:55:41 AM EST

Amazing, I am verrry impatient to read part 2, I have followed every step of the tutorial, it worked perfect in a few minuts.
Can't wait for the rest :))


IoT & Smart Cities Stories
The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next...
DXWorldEXPO LLC announced today that Big Data Federation to Exhibit at the 22nd International CloudEXPO, colocated with DevOpsSUMMIT and DXWorldEXPO, November 12-13, 2018 in New York City. Big Data Federation, Inc. develops and applies artificial intelligence to predict financial and economic events that matter. The company uncovers patterns and precise drivers of performance and outcomes with the aid of machine-learning algorithms, big data, and fundamental analysis. Their products are deployed...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
All in Mobile is a place where we continually maximize their impact by fostering understanding, empathy, insights, creativity and joy. They believe that a truly useful and desirable mobile app doesn't need the brightest idea or the most advanced technology. A great product begins with understanding people. It's easy to think that customers will love your app, but can you justify it? They make sure your final app is something that users truly want and need. The only way to do this is by ...
CloudEXPO | DevOpsSUMMIT | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Cell networks have the advantage of long-range communications, reaching an estimated 90% of the world. But cell networks such as 2G, 3G and LTE consume lots of power and were designed for connecting people. They are not optimized for low- or battery-powered devices or for IoT applications with infrequently transmitted data. Cell IoT modules that support narrow-band IoT and 4G cell networks will enable cell connectivity, device management, and app enablement for low-power wide-area network IoT. B...
The hierarchical architecture that distributes "compute" within the network specially at the edge can enable new services by harnessing emerging technologies. But Edge-Compute comes at increased cost that needs to be managed and potentially augmented by creative architecture solutions as there will always a catching-up with the capacity demands. Processing power in smartphones has enhanced YoY and there is increasingly spare compute capacity that can be potentially pooled. Uber has successfully ...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...