|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV SYS-CON.TV WEBCASTS |
TOP COLDFUSION LINKS CF Techniques ColdFusion Everywhere PART 1
Create applications that run on the Web, from CD, or on the desktop
By: Phil Cruz; Dick Applebaum
Jan. 18, 2005 12:00 AM
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...
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 ApplicationsCF 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 A Web Site On a CD 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 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 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 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:
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 ComponentsTo 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:
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:
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>/</Arg>
<Arg><SystemProperty name="jetty.home" default="."/>/wwwroot</Arg>
<Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>
</Call>
(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" /> <cfoutput>#message#</cfoutput> <br/> <br/> <br/> <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:
YOUR FEEDBACK
CFDJ LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||