Welcome!

You will be redirected in 30 seconds or close now.

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

Related Topics: ColdFusion

ColdFusion: Article

ColdFusion Developer's Journal Special "Frameworks" Focus Issue: onTap

Using the onTap framework to reinvent the Pet Market application

I must admit to having been excited at the prospect of the Pet Market frameworks project when Simon proposed it to us at the Fusebox & Frameworks Conference in September. I once tried to do something similar by creating a small blog application using the three popular frameworks that I was aware of at the time (Fusebox 3-4 and Mach-II) and the onTap framework.

Unfortunately I did all the work myself and didn't have a great venue like the ColdFusion Developer's Journal to publish the results. In the end I think my efforts at a useful comparison of frameworks fell short of what I'd hoped. Naturally I'm excited to see Simon take the initiative to enlist the aid of various framework authors and publish the results in the journal. Although I personally lament the fact that the Pet Market application isn't perhaps an ideal medium to demonstrate the unique strengths or advantages of some frameworks (not only the onTap framework, although in my case display tools in particular spring to mind), I do believe the Pet Market application provides probably the best neutral ground for comparison.

My own conversion of the Pet Market application took a bit longer than I expected. At first I thought it was good that the Pet Market application was designed purely for demonstration purposes and wouldn't be used in a production environment.

On further reflection I wonder if perhaps the opposite is true - that the original application is worse for its attempts to educate programmers new to ColdFusion because anyone using it as a learning tool is apt to learn some bad habits. Here are a few examples of what I mean: no primary keys or foreign key constraints in the database containing many related tables (no enforcement of referential integrity); display code executed in a domain-model CFC; and serpentine multi-step form templates containing both form display and post logic in the same file. I'll omit my complaints about the way in which multiple historical postal addresses are stored. Having said all that, here's an application ripe for the kind of structure any good framework will provide.

A Statement of Benefits
Here's a brief list of the benefits I've found using the onTap framework to reinvent the Pet Market application in no particular order.

  • Eliminated code while simultaneously adding functionality
  • Replaced ad hoc queries with Object Relational Mapping (ORM) and vendor-agnostic SQL abstraction
  • Convenient caching of domain-model objects (products, categories, etc.)
  • Products in the shopping cart are locale-specific, dictionary-order sorted (i18n)
  • All files located in a single parent directory (no CustomTags directory or other external resources)
  • Elimination of the custom tag for the application's layout (individual content templates don't reference the layout tag/template - decreases coupling of the content and format)
  • Automated branding of images (home page graphics differ from the remaining site)
Due to time constraints and project requests from Simon, I was unable to implement any of the XHTML or form-management and validation features of the framework and as a result can't list them as benefits in using the framework in this instance although under normal circumstances I would have. The onTap framework's form tools would have replaced a fair amount of custom form validation code in this application in a manner that provides identical client-side and server-side validation with very little coding on my part. The XHTML features would have also provided a more modular method of generating the display, allowing anyone who might license my application to easily modify the display without editing any of my code, eliminating headaches related to later upgrades of my original software.

A Place for Everything and Everything in its Place
Because the onTap framework is designed to take advantage of directory structures, getting started with the migration of Pet Market to this framework is easy. First I created a /petmarket/ directory under my framework application root directory in which the Pet Market sub-application would execute. In this directory I put a copy of all the ColdFusion templates in the original application's /wwwroot/ directory. I could have put these templates in the framework root directory, although I didn't want to create a separate copy of the onTap framework core (3MB) for only the Pet Market application, so I created the subdirectory so it could execute as a sub-application under my existing framework installation. Then I copied the new /petmarket/ directory also into the framework /_components/ directory to mirror the root directory. Files in the root directory will be directly accessible to browsers, while files in the /_components/ directory won't (they're protected by an Application.cfm template). Once these files are copied, I replace the contents of each of the templates in the root /petmarket/ directory with a one-line cfinclude tag to drive the framework content:

<cfinclude template="#request.tapi.process()#">

This sort of minimalist index template should be familiar to anyone using Fusebox, Mach-II, Model-Glue, or the Hub. What's different in this case is that we have many Web-accessible templates instead of having all page requests routed through index.cfm.

To be fair the same can be done also with any of these other frameworks, although the other frameworks are rarely implemented this way because they don't inherently gain any noticeable benefit from using this structure and as such it's generally easier to simply route all requests through the index.cfm template. However, with the onTap framework the name of the base template is used as a part of the execution path to determine which templates are executed by the framework. So using cart.cfm has an inherently different result than using index.cfm as the base template. Of course there's nothing preventing you from routing all requests through index.cfm, although using this multi-template strategy let me migrate the application more quickly thanks to not needing to edit any of the links, form targets, or cflocation tags in the application. Had I used any of these other frameworks, which use form/url parameters and XML configuration files to direct their execution, they would have required that I edit every URL in the application to add the appropriate event parameter (FuseAction, event, etc.).

Although I chose a directory structure that let me ignore URLs in the application, I chose not to take the same approach with images. Although I could have simply left the Pet Market images in the /ontap/petmarket/images/ directory and ignored any image tags in the application HTML, the framework provides some added features with regard to images and for this reason I decided to put the images in the framework's designated image directories.

Yup, multiple image directories.

Although most HTML applications put all images in a single directory, the onTap framework provides a method of easily targeting methods contextually to provide simple branding and replacement of images by context. Interestingly enough, the Pet Market application provides a perfect example of why I included this feature in the framework in spite of the fact that the original Pet Market authors never imagined that I would write this framework revision: more evidence that this is a good feature to have.

When you view the Pet Market application in a browser, you'll notice that the layout presents several images of different animals at the top, linked to category pages for the various categories of pets, such as dogs, cats, and reptiles. As you browse through the application, however, you might notice that a different set of images is presented on the home page than on any other page in the application. In the original application, the location of this image was tightly coupled with the layout custom tag: the layout tag contained logic to determine if the current page was the home page and displayed a different set of images (including the size of the image as part of the name of the graphic file). I put copies of each of these smaller five images in the directory /ontap/_components/petmarket/_images/category/ for most pages in the application to use, renaming them to remove the image size from its file name. This makes the image name succinct and canonical and the name of the image file accurate, even if the size of the image changes later. Then I copied the five larger images to the directory /ontap/_components/petmarket/index/_images/category/ for the home page to use with the same succinct file names.

Throughout the HTML for the application I then replaced all image tag SRC attributes with the function request.tapi.getIMG() containing the name of the target image. This function checks a series of nested image directories and returns the URL to the first image it finds. So when the layout requests request.tapi.getIMG("category/dogs.gif") it will use the image located in /petmarket/index/_images/category/ on the home page and on every other page it will use the image located in /petmarket/_images/category/.

More Stories By Isaac Dealey

Isaac Dealey has worked with ColdFusion since 1997 (version 3) for clients from small businesses to large enterprises, including MCI and AT&T Wireless. He evangelizes ColdFusion as a volunteer member of Team Macromedia, is working toward becoming a technical instructor, and is available for speaking engagements.

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
SYS-CON Brazil News Desk 02/01/06 03:38:19 PM EST

I must admit to having been excited at the prospect of the Pet Market frameworks project when Simon proposed it to us at the Fusebox & Frameworks Conference in September. I once tried to do something similar by creating a small blog application using the three popular frameworks that I was aware of at the time (Fusebox 3-4 and Mach-II) and the onTap framework.

SYS-CON India News Desk 02/01/06 02:49:28 PM EST

I must admit to having been excited at the prospect of the Pet Market frameworks project when Simon proposed it to us at the Fusebox & Frameworks Conference in September. I once tried to do something similar by creating a small blog application using the three popular frameworks that I was aware of at the time (Fusebox 3-4 and Mach-II) and the onTap framework.

@ThingsExpo Stories

ARMONK, N.Y., Nov. 20, 2014 /PRNewswire/ --  IBM (NYSE: IBM) today announced that it is bringing a greater level of control, security and flexibility to cloud-based application development and delivery with a single-tenant version of Bluemix, IBM's platform-as-a-service. The new platform enables developers to build ap...

The BPM world is going through some evolution or changes where traditional business process management solutions really have nowhere to go in terms of development of the road map. In this demo at 15th Cloud Expo, Kyle Hansen, Director of Professional Services at AgilePoint, shows AgilePoint’s unique approach to dealing with this market circumstance by developing a rapid application composition or development framework.
"BSQUARE is in the business of selling software solutions for smart connected devices. It's obvious that IoT has moved from being a technology to being a fundamental part of business, and in the last 18 months people have said let's figure out how to do it and let's put some focus on it, " explained Dave Wagstaff, VP & Chief Architect, at BSQUARE Corporation, in this SYS-CON.tv interview at @ThingsExpo, 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...
The Internet of Things is not new. Historically, smart businesses have used its basic concept of leveraging data to drive better decision making and have capitalized on those insights to realize additional revenue opportunities. So, what has changed to make the Internet of Things one of the hottest topics in tech? In his session at @ThingsExpo, Chris Gray, Director, Embedded and Internet of Things, discussed the underlying factors that are driving the economics of intelligent systems. Discover how hardware commoditization, the ubiquitous nature of connectivity, and the emergence of Big Data a...
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.
“In the past year we've seen a lot of stabilization of WebRTC. You can now use it in production with a far greater degree of certainty. A lot of the real developments in the past year have been in things like the data channel, which will enable a whole new type of application," explained Peter Dunkley, Technical Director at Acision, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that IDenticard will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. IDenticard™ is the security division of Brady Corp (NYSE: BRC), a $1.5 billion manufacturer of identification products. We have small-company values with the strength and stability of a major corporation. IDenticard offers local sales, support and service to our customers across the United States and Canada. Our partner network encompasses some 300 of the world's leading systems integrators and security s...
DevOps Summit 2015 New York, co-located with the 16th International Cloud Expo - to be held June 9-11, 2015, at the Javits Center in New York City, NY - announces that it is now accepting Keynote Proposals. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long development cycles that produce software that is obsolete at launch. DevOps may be disruptive, but it is essential.
"People are a lot more knowledgeable about APIs now. There are two types of people who work with APIs - IT people who want to use APIs for something internal and the product managers who want to do something outside APIs for people to connect to them," explained Roberto Medrano, Executive Vice President at SOA Software, in this SYS-CON.tv interview at Cloud Expo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Nigeria has the largest economy in Africa, at more than US$500 billion, and ranks 23rd in the world. A recent re-evaluation of Nigeria's true economic size doubled the previous estimate, and brought it well ahead of South Africa, which is a member (unlike Nigeria) of the G20 club for political as well as economic reasons. Nigeria's economy can be said to be quite diverse from one point of view, but heavily dependent on oil and gas at the same time. Oil and natural gas account for about 15% of Nigera's overall economy, but traditionally represent more than 90% of the country's exports and as...
The Internet of Things is a misnomer. That implies that everything is on the Internet, and that simply should not be - especially for things that are blurring the line between medical devices that stimulate like a pacemaker and quantified self-sensors like a pedometer or pulse tracker. The mesh of things that we manage must be segmented into zones of trust for sensing data, transmitting data, receiving command and control administrative changes, and peer-to-peer mesh messaging. In his session at @ThingsExpo, Ryan Bagnulo, Solution Architect / Software Engineer at SOA Software, focused on desi...
"At our booth we are showing how to provide trust in the Internet of Things. Trust is where everything starts to become secure and trustworthy. Now with the scaling of the Internet of Things it becomes an interesting question – I've heard numbers from 200 billion devices next year up to a trillion in the next 10 to 15 years," explained Johannes Lintzen, Vice President of Sales at Utimaco, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
"For over 25 years we have been working with a lot of enterprise customers and we have seen how companies create applications. And now that we have moved to cloud computing, mobile, social and the Internet of Things, we see that the market needs a new way of creating applications," stated Jesse Shiah, CEO, President and Co-Founder of AgilePoint Inc., in this SYS-CON.tv interview at 15th Cloud Expo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Gridstore™, the leader in hyper-converged infrastructure purpose-built to optimize Microsoft workloads, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Gridstore™ is the leader in hyper-converged infrastructure purpose-built for Microsoft workloads and designed to accelerate applications in virtualized environments. Gridstore’s hyper-converged infrastructure is the industry’s first all flash version of HyperConverged Appliances that include both compute and storag...
Today’s enterprise is being driven by disruptive competitive and human capital requirements to provide enterprise application access through not only desktops, but also mobile devices. To retrofit existing programs across all these devices using traditional programming methods is very costly and time consuming – often prohibitively so. In his session at @ThingsExpo, Jesse Shiah, CEO, President, and Co-Founder of AgilePoint Inc., discussed how you can create applications that run on all mobile devices as well as laptops and desktops using a visual drag-and-drop application – and eForms-buildi...
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...
Code Halos - aka "digital fingerprints" - are the key organizing principle to understand a) how dumb things become smart and b) how to monetize this dynamic. In his session at @ThingsExpo, Robert Brown, AVP, Center for the Future of Work at Cognizant Technology Solutions, outlined research, analysis and recommendations from his recently published book on this phenomena on the way leading edge organizations like GE and Disney are unlocking the Internet of Things opportunity and what steps your organization should be taking to position itself for the next platform of digital competition.
The 3rd International Internet of @ThingsExpo, co-located with the 16th International Cloud Expo - to be held June 9-11, 2015, at the Javits Center in New York City, NY - announces that its Call for Papers is now open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
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 @ThingsExpo, Andrew Bolwell, Director of Innovation for HP's Printing and Personal Systems Group, discussed how key attributes of mobile technology – touch input, sensors, social, and ...