Welcome!

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, Machine Learning , Agile Computing

ColdFusion: Article

Before and After with an AJAX Rich Internet Application GUI

A Webmaster's view

TapeTrader.com is a ColdFusion-powered, live music sharing community with over 50,000 members and a vast database cataloging hundreds of thousands of hours of live music recordings. The TapeTrader.com community connects fans together so that they can catalog, share and trade their recordings.

In addition to my day job at StubHub and my personal project running (ColdFusion powered) GuitarsAndMore.com, I contribute some engineering time to the TapeTrader.com community. You get the idea... I'm a live music fan!...and kind of a nerd.

When TapeTrader.com wanted to update its live recording catalog user interface, we turned to AJAX and TIBCO's General Interface software to provide a feature rich GUI that looks and feels more like a desktop application than a standard Web application. Using the General Interface AJAX libraries and visual AJAX tools, which TIBCO Software recently provided for free, made the job quick, painless and fun.

This article discusses how we transformed our existing CFML/HTML pages into XML services optimized to work with the TIBCO General Interface (GI) AJAX libraries.

Before and After
The old HTML pages generated with CFML were good, but not great. Some members have huge show lists and paging through the results could be tedious, not to mention the extra load put on the database and Web servers (and don't get me started about maintenance).

It was decided, instead, to create a system that could transfer the entire result set to the browser using XML, which made the process of exploring a catalog of recordings a client-side process. By running the Catalog Explorer application on the client, we can deliver a much richer and friendlier user experience. As shown in Figures 1 and 2, this application provides the ability to explore a member's list, add selections to your "favorites," and see a recording's details, all within a single screen. The legacy HTML application required many separate pages/pop-ups and cumbersome server calls to facilitate that same interaction.

Architectural Choices
Running the JavaScript application in the browser prevents the need for page refreshes for each interaction. It also allows us to send query result sets from the database to the browser in a single request as opposed to the constant querying and subset pagination that is required with the standard HTML page interface (see Figure 3). This not only reduces the number of hits to the server, but also improves the user experience by eliminating the latency of HTTP requests and server-side processing time.

The General Interface libraries map well with these concepts. They provide the rich user interface controls we need, as well as an "XML data cache" object and easy-to-use data-binding mechanisms to bind our XML to our GUI (see Figure 4). It was relatively easy to modify our current CFML routines that were previously used to process, generate, and send XML files to be consumed by the client-side GI user interface. Because these new ColdFusion scripts are pure data services, the XML feeds can be used in other applications or given to users to implement as they wish.

Creating Our AJAX Rich Internet Application
GI's visual development environment (GI Builder) makes it fast and easy to create a feature-rich user interface. GI Builder provides many out-of-the-box GUI components that you simply drag and drop together to create any user interface you like. Styles are set using the component properties or by using CSS. GI Builder's event editor makes it simple to bind JavaScript functions to user interface components, and the JavaScript editor provides menu-based references to the more than 100 Java Script class objects that make up the underlying GI Framework. Asynchronous communication classes, data-caching objects and many other goodies are packed right into the GI Builder environment. GI Builder provides wizards for connecting to XML, SOAP, JSON and CSV data services, as well as nifty debugging and logging capabilities which are very useful when creating JavaScript applications. If necessary, GI Builder can connect to JSON and other HTTP service types via GI APIs. You can find a lot of great documentation, tutorials and chat boards at the TIBCO Website (www.tibco.com/devnet/index.html).

The source code for the GI project demonstrated in this article can be downloaded from the online version of this article at http://coldfusion.sys-con.com. You can view the source files with any editor, but it is best to use GI's visual editor as GI Builder is optimized for GUI file types. You can download GI Builder for free at www.tibco.com/devnet/index.html.

Let's start by creating our ColdFusion data services, and then we'll create the UI and bind it to the GI AJAX application.

Server-Side Code
Listing 1 shows the original ColdFusion code which generated the HTML for the Catalog Explorer. A couple of queries are executed against the database, the results are looped through with some conditional logic, and HTML is generated and sent to the browser. Pretty standard ColdFusion stuff.

Recall that in GI applications, HTML is not needed. The UI is generated by the client-side GI framework in the browser. To create our new application, we can strip the code in Listing 1 down to its very basic elements that provide the needed data as a simple data service. To do this, we need to define how the XML response from the server should be structured such that the client-side GI app can consume it.

GI's Common Data Format (CDF)
While GI can work with any XML, SOAP, JSON or CSV source, its GUI components are set up to bind to what it calls Common Data Format (CDF). CDF is a simple XML schema for describing data where each unit of data is bounded by a <record> node. <record> nodes can contain other <record> nodes to describe hierarchical relationships. The <record> node is used as a pre-set delimiter to which GI's GUI objects can automatically bind. The <record> node thing is handy, but one has to wonder a bit why any XML wouldn't work if you could just specify <artist> as a delimiter and iterate on <artist>... but anyway, that's how GI works.

Luckily, if you do happen to have a data source that comes from a service that's not in the CDF format, GI Builder provides both visual tools and APIs that let you transform these XML structures into and from GI's CDF format. This allows you to preserve the semantics of the original XML while allowing GI's CDF to simplify client-side development. Tip: For large data sets, be sure to use the .compile() method for XML to XML transformations. This will use a faster XSLT processor that is much more efficient than JavaScript.

For simplicity, our application uses ColdFusion to generate the data feed in the CDF format. Listing 2 shows what we need our CFML to generate for client-side consumption.

Listing 3 shows the CFML service used to generate the CDF data feed. Note that we reused the query from the original source code, but added the extra detail needed for this data feed. We are getting nearly all the data we need in a single query operation, then generating a hierarchical GI's CDF data feed as output instead of generating HTML. This method of development allows the ColdFusion code to be much simpler and cleaner, and since we're not sending HTML requests back and forth, we significantly decrease bandwidth, server and database utilization. Once the data is sent to the client, the trader has all the data necessary to browse the entire collection of another trader.

Note the inclusion of the prepareGiOutput() function, which adds an XML header tag, and the root <data> node required by GI's CDF schema, and removes extra, unnecessary white space (speed is everything, after all).

Connecting the Client Application to the Data Service
Listing 4 shows the JavaScript code that is part of the client application. This code uses GI's jsx3.net.Request class to asynchronously call the ColdFusion XML service we created earlier as a GET operation. Any input the service needs (in this case, trader_id) should be passed as URL variables. Upon receiving the response XML from the service, the data is put into cache and the data grid component updates its view (a pattern consistent with the standard Model-View-Controller architectures). GI's data grid class is called a Matrix. The Matrix control can render as a grid, a list, or a tree with a variety of cell edit mask types. jsx3.gui.Matrix also implements the jsx3.xml.CDF interfaces and can contain columns of the type jsx3.gui.Matrix.Column. Like all GI GUI components, the Matrix component in GI Builder is configured through the properties editor or through JavaScript APIs. Tables 1 and 2 show the core properties needed to establish the binding between the Matrix data grid component and the CDF data in the cache.

Other Matrix and Matrix Column properties enable you to configure the sub-categorization of data, tune the pagination and expand/collapse display of data, and stylize the look and feel of the control (see Figure 5).

A Note about Security
Security seems to be one of the development community's concerns these days regarding AJAX. One of the nice things about the approach outlined earlier is that, from a security point of view, it all works within the existing Browser/Server security infrastructure with which, from the last decade of Web application development, we're all familiar. We could authenticate and control access to the .cfm processes that return XML the same way we would for any other HTML page. Further, by using XML as opposed to JSON, the client-side application is less subject to code-insertion risks since the data stream never needs to be evaluated on the client. Since XML is also piped through the XHR object in the browser by GI, it benefits from the XHR's restriction to talk to data services only from the same server as the containing page.

This restricts cross-site scripting and (unless you want cross-site scripting) is a good thing. For solutions like mashups, when using the XHR or GI, usually one will set up a gateway to the remote data domain in the form of a server proxy. This server proxy also gives an added place to implement security policies, and to log and monitor traffic between your primary security context and other security contexts. Most security concerns popping up today are from people making the same kinds of mistakes that we made seven or eight years ago in relation to CGI processes and the like. But this topic could be the subject of another paper, so let's just stop here for now.

Conclusion
AJAX not only enables a richer end-user experience, it also promotes the creation of data services that can be reused by multiple applications. This article explored how the AJAX Rich Internet Application toolkit TIBCO General Interface can be used to rapidly create rich interactive GUIs that could be used in conjunction with CFML pages that output XML rather than HTML.

Resources

  • TIBCO Developer network site provides TIBCO General Interface AJAX Rich Internet Application Toolkit downloads, video tutorials, documentation, sample applications and discussion forums: http://developer.tibco.com
  • Source code for the GI application used in this article can be found here: at the online version at this article at http://coldfusion.sys-con.com.

  • More Stories By Nate Weisiger

    Nate Weisiger is a software engineer and Web developer for stubhub.com and guitarsandmore.com, and tapetrader.com.

    Comments (2) 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
    brian 12/09/06 08:44:24 PM EST

    Great article. One question from a project planning standpoint: how long did the change to GI take you?
    Also, were you able to delegate style decisions to a designer (as opposed to a programmer)?

    brian 12/09/06 08:43:33 PM EST

    Great article. One question from a project planning standpoint: how long did the change to GI take you?
    Also, were you able to delegate style decisions to a designer (as opposed to a programmer)?

    @ThingsExpo Stories
    Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, will discuss some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he’ll go over some of the best practices for structured team migrat...
    SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
    SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
    Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they bu...
    Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, will discuss how from store operations...
    As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
    Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
    SYS-CON Events announced today that Datera will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Datera offers a radically new approach to data management, where innovative software makes data infrastructure invisible, elastic and able to perform at the highest level. It eliminates hardware lock-in and gives IT organizations the choice to source x86 server nodes, with business model option...
    With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
    Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
    Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
    SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
    SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
    Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
    SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
    SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
    SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
    SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
    High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
    In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...