Welcome!

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

Related Topics: ColdFusion

ColdFusion: Article

Using Databases Wirelessly: ColdFusion, Fusebox, and WML

Using Databases Wirelessly: ColdFusion, Fusebox, and WML

In this article we describe how combining WML, ColdFusion, and the Fusebox methodology enables wireless data updates of the data- base of a working e-commerce Web site. To provide some context, we begin with a discussion of what this Web site is and what it does.

NetLook, Inc., is a client of our company, Applied Digital Solutions' Oracle Practice. Its Web site (www.netlook.com) is designed to advertise used cars and help people find jobs (see Figures 1 and 2). NetLook lives in a cluster environment of two NT servers, each running IIS, and ColdFusion Server. These servers also hold the file system that contains auto, job, and customer files (e.g., auto pictures and customer logos).

Heavily involved with multimedia, NetLook presents information via a dedicated cable television station and weekly hard copy publications, as well as over the Internet.

One of NetLook's main features is that the job- and car-related data for these three communication channels comes from a single Oracle database. For the Internet, ColdFusion Server reads the information from the database and then displays it on the NetLook Web site.

A two-step process generates two hard- copy publications, one devoted to automobile sales, the other to job ads. First, a ColdFusion program extracts all the data (car pictures, dealer logos, and car and dealer information) from the file system and the database. Quark then uses this information to automatically generate the magazines.

Producing the TV-based information also involves a two-step process. As in the case with the hard copy, a ColdFusion program first extracts the information from the file system and database, then a NetLook AV specialist synthesizes this information for production into a televised broadcast.

The Role of ColdFusion
Visitors to the NetLook Web site access the database through a front-end written in ColdFusion. To modify the data, NetLook employees also access the database through a ColdFusion-based user interface. They enter data and photographs into this interface, then upload them. In the case of used cars, NetLook provides a marketplace for dealers as well as for individuals. An auto dealership can have its own Web page on the NetLook Web site. To accomplish this, NetLook creates frame-based HTML code for each dealer.

A dealer can select from many types of information (e.g., financing, contacts, inventory) and then display that information on his or her own site. The frame-based architecture enables the dealers to upload their own HTML pages, have those pages appear in sections of the screen, and maintain the navigation across them.

Dealers, of course, often have to modify their own NetLook-based data to keep it current, and ColdFusion is also the basis for the user interface through which they do this.

NetLook and the World of Wireless
With the increasing emphasis on wireless technology and the emergence of WAP and WML, it's possible to add the wireless data update dimension to the NetLook database. Specifically, the combination of ColdFusion with WML forms the basis for an exciting new capability - a capability that enables a NetLook employee to use a wireless phone to accomplish data update.

The modified data is then immediately available over the Internet, on NetLook's next cable TV show, and for the next issues of its hard-copy publications.

In the rest of this article we describe the nature and structure of the programming that makes the data update possible via wireless technology. We also discuss Fusebox, the methodology that's the basis for the code. The programming centers around a wireless phone emulator, available from www.phone.com (see Figure 3). The code is easily transposable to cell phones, with minor modifications to adapt to specific phones.

Working with WML: Concerns and Constraints
Dubbed a deck, a WML program consists of cards. Each card corresponds roughly to one screen, although device-centric display constraints sometimes entail additional screens for the displayed information.

Code that might encompass multiple HTML files can often appear in a single WML file that consists of many cards. Nevertheless, download constraints typically limit the size of a WML file. It's also the case that all cards within a deck are downloaded at the same time. This sets up another type of constraint: if one card initiates server-side processing based on user input to a display generated by a different card, these two cards must reside in separate decks.

How is WML processed? Wireless Internet providers typically offer a service that translates WML requests into HTTP requests. Each HTTP request then goes to a ColdFusion/IIS server, which processes the request, then a ColdFusion program generates a WML file and sends it back to the end user's wireless device. Both the device-centric and download constraints we mentioned before pertain to this generated WML file, not to the ColdFusion program that created it.

Fusebox: Structured Programming for a Stateless World
A hand-in-glove fit with WML, the Fusebox methodology forms the framework for the wireless NetLook programming. Similar to structured programming of several decades ago (as typified by the Modula-2 programming language, for example), this methodology sets up a main program whose explicitly delineated components interact with outside programs (i.e., modules). As with structured programming, a main objective of Fusebox is to enable multiprogrammer teams to work seamlessly on large projects.

Fusebox is different from earlier structured programming techniques - it turns them inside out. In classical structured programming the main program is a sequence of calls to functions and subroutines that carry out the bulk of the processing. In contrast, the Fusebox methodology's main program is a switch statement (denoted by a tag). Each case in the switch statement (denoted by ) carries out a processing module and serves as a target for external calls to the main program.

Parameters in an external call determine the case of the switch statement that activates and completes its tasks. Statelessness necessitates this. Because the main program doesn't track or remember its own state, the switch statement provides an easy mechanism for entry into the appropriate point of the main program and for sequencing the processes it carries out.

In ColdFusion, this main program is usually called index.cfm and should handle every request sent to the server. A parameter, usually named fuseaction, plays a key role in helping the server figure out what the user needs. Typically, the fuseaction contains values such as "login", "logout", or "save_info". The list of values for this parameter should encompass all the different actions the user is allowed to perform. Additional parameters may be needed to complete the request. When using the fusebox methodology to write an application, the programmer must make sure that the fuseaction values handle all the use cases. (For more information on this methodology, visit www.fusebox.org.)

Conventions
Naming conventions are extremely important in our framework. They make it easy to follow how filenames for cards are constructed, how one card's code references another card, and how a card references decks. Knowing our conventions will also help you follow Listing 1. (Listings for this article can be found on the CFDJ Web site, www.sys-con.com/coldfusion/sourcec.cfm.)

Each file whose name begins with dsp_ contains the WML for one card. If the card requires SQL to load the relevant information to the page, the SQL must be included.

To clarify the discussion, imagine two cards. Each card in a deck must have a card ID, so let's say the IDs for these cards are CardID1 and CardID2.

Our convention uses the card ID in the filename by prefixing it with dsp_ and adding a .cfm extension. So the name of the first card's file is dsp_CardID1.cfm and the name of the second one's file is dsp_CardID2.cfm. Listing 2 shows one of our dsp_ files, dsp_message.

Suppose CardID1's code has to reference CardID2. In a do statement within CardID1 a variable suffixed with _href gets that done. By our convention, the name of that variable will be CardID1_href, and the value it holds will be #CardID2.

An _href-suffixed variable can also handle a reference to a deck. If CardID1's code has to reference a deck, the variable Card-ID1_href appears in a do statement and its value is index.cfm?fuseaction = deckaction, where deckaction refers to the fuseaction of the referenced deck (i.e., to the use case that the deck's fuseaction fulfills).

Two more conventions and then we're done:

  1. Act_ file: Performs an action on the server side, such as updating the database or setting a variable. These files are strictly ColdFusion programs.
  2. App_ file: Contains code used by every program in an application. This type of module might contain global variables and security checks.
Putting It All Together
Each time the user submits a page a new request is generated for the index.cfm page and a specific value for the fuseaction parameter is passed.

The fuseaction value refers to one of the cfcase statements, which then executes. Each cfcase statement holds a series of cfset and cfinclude statements. The cfset statements define the value of the variables used within the templates that are included in the cfinclude commands.

Each cfcase may refer to zero, one, or more dsp_ files. If no dsp_ files are included, the request is processed in the background. An example is . This particular cfcase retrieves information from the database about a particular car and initializes WML variables.

A cfcase can refer to a single dsp_ file for two reasons. First, only one dsp_ file may be included if the card displays information that depends on user input to a previous card. Second, the size of the card's content may create a download constraint, leaving no memory available to download additional cards.

In our index.cfm file (see Listing 1), provides an example of both possibilities. This code displays all the models for the particular make that the user entered via a previous card. Because the model depends on the make, these two cards must reside in separate cfcase statements. Also, the list of models might be very long, leaving no room to download other cards.

Two or more cards might be in the same deck if the cards' contents leave enough space to download more than one. Typically, however, it's best to keep them in separate dsp_ files to maintain flexibility. If it becomes necessary to shuffle cards, it's easier to do it if they're in separate files.

Wireless NetLook: How It Works
Listing 1 shows the main program, index.cfm. One overall point about the code further reinforces Fusebox's value: index.cfm contains business logic and is written in ColdFusion. The WML resides in other files (e.g., in ColdFusion modules), is interspersed with ColdFusion, and performs actions such as information display and server-side processing. Thus Fusebox separates business logic from the rest of the code. If the logic changes, major surgery isn't necessary to modify the program.

The first three cases in the switch statement deal with login and session monitoring. The fourth case confirms login and displays a menu for the end user.

The next case - the one that begins with - responds to the user's menu selections. The case after that () allows the user to select the auto dealership in which he or she will update auto information.

These two cases work together in a special way. The menu items work from the premise that the user has selected a dealer. The normal sequence, then, is for the user to select a dealership before the menu displays. Sometimes, during the course of a session, the user has to update car information from a different dealer so the "sel_customer" case must come into play again. For this reason the "menu" case and the "sel_customer" case generate the same cards. The net effect (pardon the pun) is to eliminate repeated downloads of the menu. To understand menu creation and operation in greater detail, see the sidebar "Custom Tags for Menus and Menu Items."

In either case, the user enters a VIN (vehicle identification number) for a particular automobile. If that VIN is in the database, the next case () populates onscreen fields with appropriate values for the car that corresponds to the VIN. If that VIN isn't in the database, obviously the user must supply values for these fields.

How does the user modify or supply those values? The next seven cases, in which "value" ranges from "autodeck1" through "autodeck7", deal with the user's entries that update the fields. Each case displays information, gets a piece of data update-related input from the user, and uploads to the WAP server. After each upload, the WAP server generates an HTTP request and sends it to the ColdFusion/IIS Server, where a ColdFusion program generates WML that goes back to the wireless device. The code sent back to the wireless device specifies that the next case should activate, get user input, repeat the process, and further augment the parameter list. As the program progresses, each case of the switch statement adds a parameter to a list of parameters.

When the user has finished updating, the last of these case statements sends the fully built list of parameters to the ColdFusion server. Then the next case () runs SQL code that uses that list to update the database.

Wrapping Up
The wireless work we described is a significant step forward for NetLook and our company. It paves the way for NetLook to reach its customers and users in an important new dimension and sets up our work for a variety of clients in the wireless future. Experiments that use this code in conjunction with a NexTel phone have been successful.

We feel that Fusebox represents a significant portion of this effort. This methodology has enabled the creation of an architecture that positions the business logic of the system in a central block of code and puts the nuts and bolts of the processing in supplementary modules.

In addition to the obvious facilitation of development and maintenance, this type of architecture holds another important advantage: when bandwidth increases (as it always does!), it'll be possible to take advantage of the increased capability by adding more cards to a deck. This will facilitate downloading and display without tearing apart the fundamental structure of the program.

More Stories By Margarita Laplaza de Androuin

Margarita Laplaza de Androuin is a senior consultant at Applied Digital Solutions' Oracle Practice. A graduate of Harvard University, she's the technical lead for
NetLook development.

Comments (0)

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.


@ThingsExpo Stories
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...
SYS-CON Events announces a new pavilion on the Cloud Expo floor where WebRTC converges with the Internet of Things. Pavilion will showcase WebRTC and the Internet of Things. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices--computers, smartphones, tablets, and sensors – connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades.
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...
As the Internet of Things unfolds, mobile and wearable devices are blurring the line between physical and digital, integrating ever more closely with our interests, our routines, our daily lives. Contextual computing and smart, sensor-equipped spaces bring the potential to walk through a world that recognizes us and responds accordingly. We become continuous transmitters and receivers of data. In his session at Internet of @ThingsExpo, Andrew Bolwell, Director of Innovation for HP’s Printing and Personal Systems Group, will discuss how key attributes of mobile technology – touch input, senso...
SYS-CON Events announced today that Gridstore™, the leader in software-defined storage (SDS) purpose-built for Windows Servers and Hyper-V, 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. Gridstore™ is the leader in software-defined storage purpose built for virtualization that is designed to accelerate applications in virtualized environments. Using its patented Server-Side Virtual Controller™ Technology (SVCT) to eliminate the I/O blender effect and accelerate applications Gridsto...
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...
Connected devices and the Internet of Things are getting significant momentum in 2014. In his session at Internet of @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, will examine three key elements that together will drive mass adoption of the IoT before the end of 2015. The first element is the recent advent of robust open source protocols (like AllJoyn and WebRTC) that facilitate M2M communication. The second is broad availability of flexible, cost-effective storage designed to handle the massive surge in back-end data in a world where timely analytics...
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...
The Internet of Things (IoT) promises to evolve the way the world does business; however, understanding how to apply it to your company can be a mystery. Most people struggle with understanding the potential business uses or tend to get caught up in the technology, resulting in solutions that fail to meet even minimum business goals. In his session at Internet of @ThingsExpo, Jesse Shiah, CEO / President / Co-Founder of AgilePoint Inc., will show what is needed to leverage the IoT to transform your business. He will discuss opportunities and challenges ahead for the IoT from a market and tec...
SYS-CON Events announced today that TeleStax, the main sponsor of Mobicents, 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. TeleStax provides Open Source Communications software and services that facilitate the shift from legacy SS7 based IN networks to IP based LTE and IMS networks hosted on private (on-premise), hybrid or public clouds. TeleStax products include Restcomm, JSLEE, SMSC Gateway, USSD Gateway, SS7 Resource Adaptors, SIP Servlets, Rich Multimedia Services, Presence Services/RCS, Diame...
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 O'Reilly Media has been named “Media 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. O'Reilly Media spreads the knowledge of innovators through its books, online services, magazines, and conferences. Since 1978, O'Reilly Media has been a chronicler and catalyst of cutting-edge development, homing in on the technology trends that really matter and spurring their adoption by amplifying "faint signals" from the alpha geeks who are creating the future. An...
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 Transparent Cloud-computing Consortium (abbreviation: T-Cloud Consortium) will conduct research activities into changes in the computing model as a result of collaboration between "device" and "cloud" and the creation of new value and markets through organic data processing High speed and high quality networks, and dramatic improvements in computer processing capabilities, have greatly changed the nature of applications and made the storing and processing of data on the network commonplace.
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.
As a disruptive technology, Web Real-Time Communication (WebRTC), which is an emerging standard of web communications, is redefining how brands and consumers communicate in real time. The on-going narrative around WebRTC has largely been around incorporating video, audio and chat functions to apps. In his session at Internet of @ThingsExpo, Alex Gouaillard, Founder and CTO of Temasys Communications, will look at a fourth element – data channels – and talk about its potential to move WebRTC beyond browsers and into the Internet of Things.
SYS-CON Events announced today that Gigaom Research has been named "Media 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. Ashar Baig, Research Director, Cloud, at Gigaom Research, will also lead a Power Panel on the topic "Choosing the Right Cloud Option." Gigaom Research provides timely, in-depth analysis of emerging technologies for individual and corporate subscribers. Gigaom Research's network of 200+ independent analysts provides new content daily that bridges the gap between break...
We certainly live in interesting technological times. And no more interesting than the current competing IoT standards for connectivity. Various standards bodies, approaches, and ecosystems are vying for mindshare and positioning for a competitive edge. It is clear that when the dust settles, we will have new protocols, evolved protocols, that will change the way we interact with devices and infrastructure. We will also have evolved web protocols, like HTTP/2, that will be changing the very core of our infrastructures. At the same time, we have old approaches made new again like micro-services...
The Industrial Internet revolution is now underway, enabled by connected machines and billions of devices that communicate and collaborate. The massive amounts of Big Data requiring real-time analysis is flooding legacy IT systems and giving way to cloud environments that can handle the unpredictable workloads. Yet many barriers remain until we can fully realize the opportunities and benefits from the convergence of machines and devices with Big Data and the cloud, including interoperability, data security and privacy.
Swiss innovators dizmo Inc. launches its ground-breaking software, which turns any digital surface into an immersive platform. The dizmo platform seamlessly connects digital and physical objects in the home and at the workplace. Dizmo breaks down traditional boundaries between device, operating systems, apps and software, transforming the way users work, play and live. It supports orchestration and collaboration in an unparalleled way enabling any data to instantaneously be accessed on any surface, anywhere and made interactive. Dizmo brings fantasies as seen in Sci-fi movies such as Iro...