Nearly every enterprise is evaluating cloud computing solutions either today or in the near term. Many have already made the leap, and many more are getting close to putting that first toe in the water. But there are key considerations that should be made, questions to be asked, and designs to consider before you can feel secure with your provider.
In his session at the 10th International Cloud Expo, David Gulick, Product Manager, Hosting Product Management at Savvis, will help give you food f...| By Joe Danziger | Article Rating: |
|
| February 21, 2007 10:45 AM EST | Reads: |
263,784 |
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser.
The rise of AJAX over the past several months has taken over the development world and breathed new life into the Web. Although these techniques have been possible for many years now, the maturity of Web standards like XHTML and CSS now make it a viable alternative that will be viewable by all but the oldest browsers.
It's also been possible to accomplish many of the same things using Flex or Flash, but the development cycle with those applications is typically more involved and the overhead often not justified.
We're going to harness the power of the Scipt.aculo.us JavaScript library to provide our interaction. As their Web site states, this library "provides you with easy-to-use, compatible and, ultimately, totally cool JavaScript libraries to make your web sites and web applications fly, Web 2.0 style." We're also going to utilize the <CF_SRS> library to handle the actual AJAX data piping to our application. Both of these libraries are free for all to use, and they're easier to integrate than you would think.
For this article, we'll create an interactive shopping experience allowing us to add items to our shopping basket by dragging and dropping them onto an icon of a shopping cart. We'll add AJAX functionality, allowing us to update our shopping cart without redrawing the entire screen. To save the trouble of setting up a product database, we'll use Amazon Web Services to search for DVDs and use those to shop from.
Start with a blank index.cfm in your root directory. You'll need to visit http://script.aculo.us/downloads to download the latest distribution (they're nearing a final release for version 1.5 as of this writing). Copy the "lib" and "src" directories into your empty directory. You'll need all of the .js files so just copy over the entire directory in each case. Next, type the following lines into the <head></head> section of your page:
<script src="./lib/prototype.js" type="text/javascript"></script>
<script src="./src/scriptaculous.js" type="text/javascript"></script>
We'll need a search box to submit our query to Amazon:
<form action="index.cfm" method="post">
Search: <input type="text" name="keywords" size="20" />
<input type="submit" name="search" value="Go" />
</form>
The page will look for a form.search variable and run an Amazon search when it is defined. Each item returned will be placed in its own styled div that will be able to be picked up and dragged.
The Scriptaculous library makes it easy to create "draggables" (the only required argument is the ID of the object that you want draggable). Listing 1 contains the code to search Amazon and return the results as draggable divs.
At this point, all of the items returned from the search will be in their own box and should be draggable around the screen. When we created each draggable, we set "revert=true", which will snap each object back to its original location if not placed directly on a drop zone.
Next, we'll add a graphic of a shopping cart to our page, which will become a drop target on which to drag items. The Scriptaculous library also makes it easy to create these "droppables". The syntax is simply:
Droppables.add('id_of_element',[options]);
The code below creates a droppable zone of id "cart1" and also runs a function onDrop() that pops up an alert box letting the user know an item has being added. We then hide the element from view, which allows the other divs to slide over and adjust accordingly.
<img src="shopcart.jpg" id="cart1" style="float:left;">
<script language="javascript" type="text/javascript">
Droppables.add('cart1', { onDrop:function(element) {
alert('Added UPC ' + element.id + ' to your shopping cart.');
Element.hide(element.id);}})
</script>
The items should now be disappearing when dropped onto the shopping cart, but there's nothing going on behind the scenes yet. Now it's time to add some AJAX to process our shopping cart.
Although there are several AJAX libraries to choose from, we're going to use the ColdFusion Simple Remote Scripting <CF_SRS> library made available free of charge by Matthew Walker of ESWsoftware in New Zealand. <CF_SRS> uses an IFRAME for communication and encapsulates all of the dirty work for you. This library was chosen for its ability to handle HTML tables well and for its ability to interact directly with the browser's Document Object Model (DOM) to output our shopping cart rows.
We'll start with an empty cart by including the following code:
<fieldset style="width:400px;">
<legend>Your shopping cart</legend>
<table border="0" cellspacing="0" cellpadding="5" id="tableCart">
<thead></thead><tbody></tbody></table>
<button onclick="emptyCartButton_onClick()" id="emptyCartButton">
Clear Shopping Cart</button>
</fieldset>
(Don't worry about the fact that our table body (<tbody></tbody>) is empty right now - we'll be populating it in just a second through AJAX.)
Next, you'll need to download the <CF_SRS> package from www.eswsoftware.com/products/download/. Copy the srs.cfm file into your Webroot (or you can add it to your CustomTags directory if you plan to do more AJAXing). You'll also need to create a subdirectory to hold the gateway pages that handle our AJAX data passing. Name the directory "SRS" and copy the Application.cfm and OnRequestEnd.cfm files into there from the "serverpages" directory in the zip file. You can use either regular CFM files or CFCs for these gateway pages (the download provides examples of each). The main thing to remember is that these pages should always return their results to "request.response".
Simply adding a <cf_srs> call to your page will handle the creation of the hidden IFRAME for you. Another great feature of the CF_SRS library is the ability to view an inline debugging window right inside the page you are working on. This allows you to see all of the data being passed back and forth through the gateway. You can enable this debugging by calling the tag as <cf_srs trace>. This line can be placed anywhere but we'll add it at the very end of the file.
Next, we'll need to create some JavaScript functions to handle the AJAX interactions. Add an onLoad function to your body tag as such: <body onload="body_onLoad()">. This will execute body_onLoad() when the page loads and we'll use this function to set up our gateway. The function should read as follows:
function body_onLoad() {
// create an SRS gateway to the cart.cfm page
objGateway = new gateway("srs/cart.cfm?");
// update cart in case of return visit
// code for this function is below
updateCart();
}
Once you have created your gateway, you can invoke the methods below to send requests to the server:
- objGateway.setListener( str ): Use this method to specify the name of the function in your Web page that will handle the server's response. str is a string representing the function's name. The listener defaults to "alert", which will pop up a JavaScript alert() box containing the server's response. Note that while ColdFusion is a case-insensitive language, JavaScript is case-sensitive. If you return a structure to your listener function, all the structure keys will be rendered in JavaScript as lowercase.
- objGateway.setArguments( obj ): Set the arguments and values to pass to the server. obj is an object literal, which is basically just a set of one or more attribute/value pairs wrapped in curly braces. Here's an example: { name:'Joe', age:30, country:'US' }. You can see that string values need to be wrapped in quotation marks, and colons (:) are used in place of equals signs (=).
- objGateway.resetArguments(): Remove all the arguments previously set.
- objGateway.request(): Send the request to the server.
Published February 21, 2007 Reads 263,784
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Joe Danziger
Joe Danziger is a senior web applications developer with Multimax, Inc., a provider of Enterprise IT Services and Solutions supporting the critical missions of the Air Force, Army, Navy, and other Department of Defense components. He is certified as an Advanced Macromedia ColdFusion MX Developer, and also maintains the Building Blocks site (www.ajaxcf.com) dedicated to AJAX and ColdFusion, as well as DJ Central (www.djcentral.com), a Website serving DJs and the electronic dance music industry.
![]() |
King 05/21/08 03:33:54 PM EDT | |||
Soon everything will be Ajax, just look how the major websites are adapting to use it. |
||||
![]() |
A 05/07/08 01:02:58 PM EDT | |||
I think your right when you say that Ajax is the way of the future, although its is difficult to program, you can see yahoos and googles implementation of it. |
||||
![]() |
Scott 08/02/07 12:04:03 PM EDT | |||
Hello N, I had the same problem. Try changing: to: |
||||
![]() |
N 07/14/07 10:19:57 AM EDT | |||
I'm following this tutorial to the letter as well and I also get this error in the code that retrieves the info from Amazon... Element ITEMS.TOTALRESULTS.XMLTEXT is undefined in XNSEARCH Is there a fix available or anything to get this to work. It looks good though. N |
||||
![]() |
asdf 07/10/07 01:17:36 AM EDT | |||
asdfsafs asdfasf asdfasf |
||||
![]() |
abcd 07/10/07 01:14:52 AM EDT | |||
heloow asdf asdfs asdfasf biuiouer asdfaf boihoi awerew asdf |
||||
![]() |
Wally Kolcz 01/22/07 09:27:35 AM EST | |||
I loved your tutorial on how to make a drag and drop web cart, but I couldn't quite follow on how to put the code into the page to make it work. Do you have any finished files available for download to see how it is constructed? Thanks |
||||
![]() |
BUses 12/26/06 08:45:23 PM EST | |||
Awesome content: L'augmentation d'AJAX pendant plusieurs mois passés a repris du monde de développement et a donné un second souffle au Web. |
||||
![]() |
Simone from Italy 12/20/06 10:54:21 AM EST | |||
Hi, please add a link to index.cfm full compliled because It's very hard to have a union of all fragments introduced in your article. Thanks |
||||
![]() |
Danny 10/31/06 04:09:38 AM EST | |||
I'm following this tutorial to the letter and I get this error in the code that retrieves the info from Amazon... Element ITEMS.TOTALRESULTS.XMLTEXT is undefined in XNSEARCH Any ideas? Thanks for this tutorial! |
||||
![]() |
j j 09/21/06 02:01:43 PM EDT | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
Student Organization Guy 08/05/06 04:28:22 AM EDT | |||
How is user experience improved with dragging items into a shopping cart? ;) This is just developer feature candy. There are many other site components to focus your time on that will improve your application. Don't work so hard just to remove your 'add to cart' buttons. |
||||
![]() |
CFDJ News Desk 08/04/06 04:20:22 PM EDT | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
AJAXWorld News Desk 08/04/06 03:46:57 PM EDT | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
AJAXWorld News Desk 08/04/06 03:46:48 PM EDT | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
AJAXWorld News Desk 08/04/06 03:35:26 PM EDT | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
AJAXWorld News Desk 08/01/06 04:10:49 PM EDT | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
barb 08/01/06 03:52:54 PM EDT | |||
I also have been struggling to get this example to work. It is not clear to me if I have to have a Coldfusion server running. Currently, I do not. I simply followed the instructions in the article. I'm getting the Javascript error "gateway not defined" from the line of code where I try to instantiate it: objGateway = new gateway("srs/cart.cfm?");. Can you please provide more information or a complete code listing? Thank you! |
||||
![]() |
bill 02/10/06 11:35:56 PM EST | |||
The app is great but I'm also struggling to get it to work. I'm not giving up! |
||||
![]() |
Kenny 02/08/06 07:10:32 PM EST | |||
This is one of the most frustrating examples I've ever tried. I cannot figure out how to assemble this application. It is not well written at all in my opinion. Why is there not a clear list of all the code somewhere? I came to the website to download the code, so I could simply paste it and watch it work. But instead I've been stressing for the last 40 minutes just trying to figure out how to get it all together, and I simply cannot. I give up! |
||||
![]() |
SYS-CON Brazil News Desk 01/27/06 02:28:32 PM EST | |||
Keeping up with the latest Web technologies is tough nowadays. Every week it seems new sites are launched that push the envelope further and further in terms of what can be accomplished using just a Web browser. |
||||
![]() |
Colm Brazel 01/24/06 08:54:51 AM EST | |||
Hi, I'm reading the online digital edition version cheers Colm |
||||
- Agile Adoption – Crossing the Chasm
- Architecture Governance – the TOGAF Way
- Cisco Unveils Visual Collaboration Solutions in the Post-PC Era, Extending the Reach of TelePresence With New Mobile-to-Immersive Offerings
- Agile Development & Enterprise Architecture Practice – Can They Coexist?
- Cross-Platform Hybrid Mobile Application Development
- Adobe Study Shows Social Media Impact Undervalued by Nearly 100 Percent
- Trends in Social Media – 2012
- Apply Agile When Deploying Apps
- The Web – Changing the Way We Work
- Cloud Expo New York: Making the Enterprise Comfortable with the Cloud
- User Group Malaise?
- Improving the Mobile Experience with HTML5
- Agile Adoption – Crossing the Chasm
- Architecture Governance – the TOGAF Way
- Cisco Unveils Visual Collaboration Solutions in the Post-PC Era, Extending the Reach of TelePresence With New Mobile-to-Immersive Offerings
- Agile Development & Enterprise Architecture Practice – Can They Coexist?
- Cross-Platform Hybrid Mobile Application Development
- Adobe Study Shows Social Media Impact Undervalued by Nearly 100 Percent
- Trends in Social Media – 2012
- Apply Agile When Deploying Apps
- The Web – Changing the Way We Work
- Oops! HTML5 Does It Again
- Cloud Expo New York: Making the Enterprise Comfortable with the Cloud
- User Group Malaise?
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- Where Are RIA Technologies Headed in 2008?
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Struts Validations Framework Using AJAX
Nearly every enterprise is evaluating cloud computing solutions either today or in the near term. Many have already made the leap, and many more are getting close to putting that first toe in the water. But there are key considerations that should be made, questions to be asked, and designs to consider before you can feel secure with your provider.
In his session at the 10th International Cloud Expo, David Gulick, Product Manager, Hosting Product Management at Savvis, will help give you food f...May. 16, 2012 03:06 PM EDT Reads: 335 |
By Jeremy Geelan With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you dealing with every nook and cranny of Cloud Computing, but what of those who are presenting? Who are they, where do they work, what else have they written and/or said about the Cloud that is t...May. 16, 2012 02:30 PM EDT Reads: 4,419 |
By Liz McMillan SYS-CON Events announced today that Super Micro Computer, Inc., a global leader in high-performance, high-efficiency server technology and green computing, will exhibit at SYS-CON's 10th International Cloud Expo, which will take place on June 11–14, 2012, at the Javits Center in New York City, New York.
Supermicro (NASDAQ: SMCI), the leading innovator in high-performance, high-efficiency server technology, is a premier provider of advanced server Building Block Solutions for Embedded Systems, E...May. 16, 2012 02:15 PM EDT Reads: 355 |
By Pat Romanski SYS-CON Events announced today that ScaleMP, a leading provider of virtualization solutions for high-end computing, will exhibit at SYS-CON's 10th International Cloud Expo, which will take place on June 11–14, 2012, at the Javits Center in New York City, New York.
ScaleMP is the leader in virtualization for high-end computing, providing maximum performance and lower total cost of ownership (TCO). The innovative Versatile SMP (vSMP) architecture aggregates multiple independent systems into a sin...May. 16, 2012 12:00 PM EDT Reads: 621 |
By Elizabeth White Come learn real-world examples where cloud and mobile are changing the way business works and the impact they're having on efficiency and productivity.
In his session at the 10th International Cloud Expo, Rodrigo Coutinho Senior Product Marketing Manager at OutSystems, will look at how mobile and the cloud are interwoven and the wave of change these two 2012 megatrends will bring to your organization. He will also provide a roadmap to assure you can navigate this sea change for business succes...May. 16, 2012 11:58 AM EDT Reads: 335 |
By Pat Romanski Enterprise IT organizations want to deploy a virtualized data center fabric that will provide the foundation for agile private cloud computing. Getting there does not have to be difficult, but it does require a new approach to data center infrastructure design – an approach that is non-disruptive, vendor-agnostic, and very adaptable to changing business requirements.
In his session at the 10th International Cloud Expo, Bruce Fingles, Chief Information Officer and VP of Product Quality at Xsigo...May. 16, 2012 10:30 AM EDT Reads: 1,583 |
By Jeremy Geelan With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...May. 16, 2012 10:15 AM EDT Reads: 1,362 |
By Jeremy Geelan With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...May. 16, 2012 10:00 AM EDT Reads: 4,921 |
By Jeremy Geelan With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you every day from June 11 through June 14 dealing with every nook and cranny of Cloud Computing and Big Data, but what of those who are presenting? Who are they, where do they work, what else have ...May. 16, 2012 10:00 AM EDT Reads: 6,165 |
By Liz McMillan May. 16, 2012 10:00 AM EDT Reads: 785 |









With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you dealing with every nook and cranny of Cloud Computing, but what of those who are presenting? Who are they, where do they work, what else have they written and/or said about the Cloud that is t...
SYS-CON Events announced today that Super Micro Computer, Inc., a global leader in high-performance, high-efficiency server technology and green computing, will exhibit at SYS-CON's 10th International Cloud Expo, which will take place on June 11–14, 2012, at the Javits Center in New York City, New York.
Supermicro (NASDAQ: SMCI), the leading innovator in high-performance, high-efficiency server technology, is a premier provider of advanced server Building Block Solutions for Embedded Systems, E...
SYS-CON Events announced today that ScaleMP, a leading provider of virtualization solutions for high-end computing, will exhibit at SYS-CON's 10th International Cloud Expo, which will take place on June 11–14, 2012, at the Javits Center in New York City, New York.
ScaleMP is the leader in virtualization for high-end computing, providing maximum performance and lower total cost of ownership (TCO). The innovative Versatile SMP (vSMP) architecture aggregates multiple independent systems into a sin...
Come learn real-world examples where cloud and mobile are changing the way business works and the impact they're having on efficiency and productivity.
In his session at the 10th International Cloud Expo, Rodrigo Coutinho Senior Product Marketing Manager at OutSystems, will look at how mobile and the cloud are interwoven and the wave of change these two 2012 megatrends will bring to your organization. He will also provide a roadmap to assure you can navigate this sea change for business succes...
Enterprise IT organizations want to deploy a virtualized data center fabric that will provide the foundation for agile private cloud computing. Getting there does not have to be difficult, but it does require a new approach to data center infrastructure design – an approach that is non-disruptive, vendor-agnostic, and very adaptable to changing business requirements.
In his session at the 10th International Cloud Expo, Bruce Fingles, Chief Information Officer and VP of Product Quality at Xsigo...
With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
With Cloud Expo 2012 New York (10th Cloud Expo) now under four weeks away, what better time to introduce you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you every day from June 11 through June 14 dealing with every nook and cranny of Cloud Computing and Big Data, but what of those who are presenting? Who are they, where do they work, what else have ...
It was at Netscape, in the early days of the internet, when co-founders Lou Montulli and Jeff Whitehead first worked together and began to notice how the amount of their data was constantly growing, but the process for adding storage and protecting that data wasn't improving over time.
"Zetta is a ...
Okay – this is easy… or is it?
Lots of people continue to perpetuate the idea that the AWS APIs are a de facto standard, so we should just all move on about it. At the same time, everybody seems to acknowledge the fact that Amazon has never ever indicated that they want to be a true standard. Are...
When it comes to building new cloud services, there is a large opportunity for new services built around Big Data.
So when you look at consulting firms that provide application development and integration services, are there opportunities for them to leverage Big Data in their service portfolio?
...
All the buzz surrounding OpenStack over the past few months may beg the question of whether Openstack can repeat for Cloud what Linux has done for server operating systems over the past several years. With an enthusiastic following and a compelling, if not industry-leading set of functionality, the ...
Throughout history there has been a cycle that ebbs and flows where new technology makes production more efficient and reduces the need for manpower in a particular space, thus forcing those in charge into the difficult position of deciding who stays and who goes. This is normally replaced by an u...
As I mentioned in my last blog post, the promise of cost reduction is compelling many enterprises to move their workloads into the Cloud but many IT leaders are reluctant to do so, for fear of compromising the security and availability of their services. These concerns are well-founded but the benef...
Late today the FedRAMP Program Management Office released the first list of certified Third Party Assessment Organizations (3PAOs). These companies are accredited to perform initial and periodic assessment of cloud service provider (CSP) systems per FedRAMP requirements, provide evidence of complian...
With HP Cloud Storage, you can access it from web browser or from Application Programming Interface (API). With Gladinet, it is much easier to access HP Cloud Storage from all major web browser with Windows Explorer like interface. It is also easy to share and collaborate with colleagues from web br...
As the role of cloud computing is growing around the globe, many CIOs and other senior IT decision makers are facing challenges with their existing network infrastructure -- to support the migration of their business applications to the cloud. A new international study by Cisco Systems revealed the ...
Major changes have taken place in the network in the past 15 years. The type of data that users are passing across the pipes is significantly different in size and composition. And, the coming “data explosion” promises to put even the most robust networks to the test.
When you add in technologies l...









