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
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, examined 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 is e...
The Internet of Things will put IT to its ultimate test by creating infinite new opportunities to digitize products and services, generate and analyze new data to improve customer satisfaction, and discover new ways to gain a competitive advantage across nearly every industry. In order to help corporate business units to capitalize on the rapidly evolving IoT opportunities, IT must stand up to a new set of challenges. In his session at @ThingsExpo, Jeff Kaplan, Managing Director of THINKstrategies, will examine why IT must finally fulfill its role in support of its SBUs or face a new round of...
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 styles ...
We are reaching the end of the beginning with WebRTC, and real systems using this technology have begun to appear. One challenge that faces every WebRTC deployment (in some form or another) is identity management. For example, if you have an existing service – possibly built on a variety of different PaaS/SaaS offerings – and you want to add real-time communications you are faced with a challenge relating to user management, authentication, authorization, and validation. Service providers will want to use their existing identities, but these will have credentials already that are (hopefully) i...
Cultural, regulatory, environmental, political and economic (CREPE) conditions over the past decade are creating cross-industry solution spaces that require processes and technologies from both the Internet of Things (IoT), and Data Management and Analytics (DMA). These solution spaces are evolving into Sensor Analytics Ecosystems (SAE) that represent significant new opportunities for organizations of all types. Public Utilities throughout the world, providing electricity, natural gas and water, are pursuing SmartGrid initiatives that represent one of the more mature examples of SAE. We have s...
"Matrix is an ambitious open standard and implementation that's set up to break down the fragmentation problems that exist in IP messaging and VoIP communication," explained John Woolf, Technical Evangelist at Matrix, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, discussed how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money!
One of the biggest challenges when developing connected devices is identifying user value and delivering it through successful user experiences. In his session at Internet of @ThingsExpo, Mike Kuniavsky, Principal Scientist, Innovation Services at PARC, described an IoT-specific approach to user experience design that combines approaches from interaction design, industrial design and service design to create experiences that go beyond simple connected gadgets to create lasting, multi-device experiences grounded in people's real needs and desires.
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 @ThingsExpo, Robin Raymond, Chief Architect at Hookflash, will walk through the shifting landscape of traditional telephone and voice services ...
Scott Jenson leads a project called The Physical Web within the Chrome team at Google. Project members are working to take the scalability and openness of the web and use it to talk to the exponentially exploding range of smart devices. Nearly every company today working on the IoT comes up with the same basic solution: use my server and you'll be fine. But if we really believe there will be trillions of these devices, that just can't scale. We need a system that is open a scalable and by using the URL as a basic building block, we open this up and get the same resilience that the web enjoys.
The Internet of Things is tied together with a thin strand that is known as time. Coincidentally, at the core of nearly all data analytics is a timestamp. When working with time series data there are a few core principles that everyone should consider, especially across datasets where time is the common boundary. In his session at Internet of @ThingsExpo, Jim Scott, Director of Enterprise Strategy & Architecture at MapR Technologies, discussed single-value, geo-spatial, and log time series data. By focusing on enterprise applications and the data center, he will use OpenTSDB as an example t...
The Domain Name Service (DNS) is one of the most important components in networking infrastructure, enabling users and services to access applications by translating URLs (names) into IP addresses (numbers). Because every icon and URL and all embedded content on a website requires a DNS lookup loading complex sites necessitates hundreds of DNS queries. In addition, as more internet-enabled ‘Things' get connected, people will rely on DNS to name and find their fridges, toasters and toilets. According to a recent IDG Research Services Survey this rate of traffic will only grow. What's driving t...
Enthusiasm for the Internet of Things has reached an all-time high. In 2013 alone, venture capitalists spent more than $1 billion dollars investing in the IoT space. With "smart" appliances and devices, IoT covers wearable smart devices, cloud services to hardware companies. Nest, a Google company, detects temperatures inside homes and automatically adjusts it by tracking its user's habit. These technologies are quickly developing and with it come challenges such as bridging infrastructure gaps, abiding by privacy concerns and making the concept a reality. These challenges can't be addressed w...
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at Internet of @ThingsExpo, James Kirkland, Chief Architect for the Internet of Things and Intelligent Systems at Red Hat, described how to revolutioniz...
Bit6 today issued a challenge to the technology community implementing Web Real Time Communication (WebRTC). To leap beyond WebRTC’s significant limitations and fully leverage its underlying value to accelerate innovation, application developers need to consider the entire communications ecosystem.
The definition of IoT is not new, in fact it’s been around for over a decade. What has changed is the public's awareness that the technology we use on a daily basis has caught up on the vision of an always on, always connected world. If you look into the details of what comprises the IoT, you’ll see that it includes everything from cloud computing, Big Data analytics, “Things,” Web communication, applications, network, storage, etc. It is essentially including everything connected online from hardware to software, or as we like to say, it’s an Internet of many different things. The difference ...
Cloud Expo 2014 TV commercials will feature @ThingsExpo, which was launched in June, 2014 at New York City's Javits Center as the largest 'Internet of Things' event in the world.
SYS-CON Events announced today that Windstream, a leading provider of advanced network and cloud communications, has been named “Silver Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. Windstream (Nasdaq: WIN), a FORTUNE 500 and S&P 500 company, is a leading provider of advanced network communications, including cloud computing and managed services, to businesses nationwide. The company also offers broadband, phone and digital TV services to consumers primarily in rural areas.
"There is a natural synchronization between the business models, the IoT is there to support ,” explained Brendan O'Brien, Co-founder and Chief Architect of Aria Systems, in this SYS-CON.tv interview at the 15th International Cloud Expo®, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
The major cloud platforms defy a simple, side-by-side analysis. Each of the major IaaS public-cloud platforms offers their own unique strengths and functionality. Options for on-site private cloud are diverse as well, and must be designed and deployed while taking existing legacy architecture and infrastructure into account. Then the reality is that most enterprises are embarking on a hybrid cloud strategy and programs. In this Power Panel at 15th Cloud Expo (http://www.CloudComputingExpo.com), moderated by Ashar Baig, Research Director, Cloud, at Gigaom Research, Nate Gordon, Director of T...