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
    DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
    "Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of the 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great deals to gre...
    The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and shared the must-have mindsets for removing complexity from the develop...
    In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
    "Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
    Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
    Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
    "Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    "IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
    In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    "Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
    Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
    "MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    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, discussed how from store operations and ...
    "There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    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...
    SYS-CON Events announced today that Telecom Reseller 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, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.