YOUR FEEDBACK
Gregor Rosenauer wrote: well, not what's your take on this? Did I miss a second page of this article or...
AJAXWorld RIA Conference
Early Bird Savings Expire Friday Register Today and SAVE !..


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP COLDFUSION LINKS


ColdFusion "Real Estate Sample Application" (Part I)
Building the search functionality with Flash Forms

This object must implement the necessary functions that will be automatically called when the server sends a response from a CFC. The default functions called on this object are onResult and onStatus. The server calls onResult when the service sends a successful response and calls onStatus when the service throws an error or when some other type of error occurs. That means that the responseHandler object must have those two functions if it is expected to act upon service responses:

responseHandler.onResult = ( results: Object ):Void {
    //handle service response
}

responseHandler.onStatus= (status: Object ):Void {
    //handle error
}

Once the responseHandler objects knows how to behave, the actual service can be instantiated and stored in a global variable (RealEstateAdmin.myGlobalObjects), as follows:

RealEstateAdmin.myGlobalObjects.listingService =
connection.getService("RealEstate.services.ListingService", responseHandler );

The getService() method of the connection class takes two parameters; the first is the path to the service. To get the path to your service, find the directory structure from your Web root to your CFC, replace the slashes with dots, and remove the CFC extension.

For instance, if you saved the sample files in a folder called RealEstate in your Web root and saved ListingManager.cfc in a folder called services, the path would be /RealEstate/services/ListingManager.cfc from a browser. Translating that to dot notation becomes RealEstate.services.ListingManager.

The second parameter is the object that handles the responses, which is the object you just created: responseHandler. Note that the service is not actually created until you call a method on the service. So if you enter an incorrect path, you will not know it until you try to call it.

Now you have a method that sets up a Flash Remoting service, but if you never call this, the service will never be set up. You can use the onload attribute of the cfform tag, which was introduced with the ColdFusion 7.01 Updater to call the service, as follows:

<cfform name="RealEstateAdmin" format="flash" onload=" setUpRemoting()">

That is not enough, however, because the service is stored in a global variable that you must also declare as the form loads. You can create yet another to be called as the form loads that sets up this global variable and possibly other settings. While you are at it, call the setUpRemoting() right after that, as follows:

<cfform name="RealEstateAdmin" format="flash" onload="formOnLoad();">

<cfformitem type="script">

formOnLoad():Void{
    //declare global variable RealEstateAdmin.myGlobalObjects = {};

//call set up
setUpRemoting();

    //set other properties as needed
}
//rest of the code

Assigning the Flash Remoting service to a global variable is only a suggestion. The most important code is what's inside the setUpRemoting().

Finally, you are ready to call the service. Your Search panel readily accepts user input. You have set up the Flash Remoting service and your CFC is eagerly waiting to be called. Remember how the Search panel had a Search button? Now you can make it functional by adding some actions to its onClick attribute:

<cfinput type="button" name="searchSubmit" value="Search" onclick="submitSearch()" />

But wait a minute. What is the submitSearch()? Because it is not built-in, you're going to create it next.

Creating the submitSearch()
Within the same <cfformitem type="script"> tag, add the new :

submitSearch():Void{

}

The purpose of the submitSearch() is to gather all the information entered in the Search panel and send it to the ListingManager service.

If you recall, the CFC has several arguments. When making the call, you could send each argument, in order, as parameters to the call. But that becomes error-prone if the CFC has many arguments. An easy way to send several parameters is to use a structure with keys that have the same name as the arguments.

To create a structure, you instantiate an empty object (or structure) that will be the container for all the data entered in the Search panel form fields. Then, one by one, take the data entered in each field and assign it to a key in the empty object, as shown in Listing 3.

Once you have gathered all the necessary data for the structure, you can make the call to your CFC, sending all the parameters as one structure. Recall that "search' was the name of the service in the ListingManager CFC:

RealEstateAdmin.myGlobalObjects.listingService.search(searchArgs);

After you call the service and the matching records are retrieved, the server will send a query back with the results, even if it is an empty query. The responseHandler object handles the response in its onResult , but if you go back to the "Calling the Service" section, you'll see that the query was empty, which doesn't help much - when the results are returned, they will just be ignored.

Adding a Grid for the Results
The sample application shows the search results in a datagrid next to the Search panel. To implement this functionality, add a grid using cfgrid and name it listingGrid:

<cfgrid name="listingGrid" rowheaders="false">
    <cfgridcolumn name="price" header="Price" />
    <cfgridcolumn name="bedrooms" header="Bedrooms" />
    <cfgridcolumn name="bathrooms" header="Bathrooms" />
    <cfgridcolumn name="footage" header="Footage" />
    <cfgridcolumn name="type" header="Type" />
</cfgrid>

Notice that the headers of visible columns are properly named and the name attribute of each cfgridcolumn tag corresponds to a query column name.

Now that you have a control, assign the results to the grid's data provider:

var listingGrid = listingGrid;
responseHandler.onResult = (results: Object):Void {
    listingGrid.dataProvider = results;
}

About Nahuel Foronda
Nahuel Foronda is one of the founders of Blue Instant (http://www.blueinstant.com), a web development firm specializing in Rich Internet Applications where he has been creating award-winning applications and offering training for the last five years. He also maintains a blog, called AS Fusion (http://www.asfusion.com), where he writes about Flash, ColdFusion and other web technologies.

About Laura Arguello
Laura Arguello is one of the founders of Blue Instant (http://www.blueinstant.com), a web development firm specializing in Rich Internet Applications where she has been creating award-winning applications and offering training for the last five years. She also maintains a blog, called AS Fusion (http://www.asfusion.com), where she writes about Flash, ColdFusion and other web technologies.

YOUR FEEDBACK
SYS-CON Belgium News Desk wrote: With the release of Macromedia ColdFusion 7 and the arrival of Flash Forms, developers were presented with an alternative to HTML forms that offered them additional functionality, such as full-featured controls not available in HTML and built-in validation.
SYS-CON Netherlands News Desk wrote: With the release of Macromedia ColdFusion 7 and the arrival of Flash Forms, developers were presented with an alternative to HTML forms that offered them additional functionality, such as full-featured controls not available in HTML and built-in validation.
SYS-CON India News Desk wrote: With the release of Macromedia ColdFusion 7 and the arrival of Flash Forms, developers were presented with an alternative to HTML forms that offered them additional functionality, such as full-featured controls not available in HTML and built-in validation.
SYS-CON Italy News Desk wrote: With the release of Macromedia ColdFusion 7 and the arrival of Flash Forms, developers were presented with an alternative to HTML forms that offered them additional functionality, such as full-featured controls not available in HTML and built-in validation.
SYS-CON India News Desk wrote: With the release of Macromedia ColdFusion 7 and the arrival of Flash Forms, developers were presented with an alternative to HTML forms that offered them additional functionality, such as full-featured controls not available in HTML and built-in validation.
CFDJ LATEST STORIES . . .
Rich Internet Applications offer the potential to fundamentally change the user experience and in doing so, yield significant business benefits. The theme of this October's AJAX World Conference & Expo 2008 West is 'Beyond AJAX to the RIA Era' and the Call for Papers, which is still op...
Join Scott Guthrie as he discusses Microsoft’s commitment to web standards development, Rich Internet Applications and how Microsoft is contributing to help move the web forward. Join Adobe’s Kevin Lynch as he demonstrates how Flash and HTML come together to make the most engaging,...
Virtualization has become a critical part of Enterprise IT strategy. Why and how has it become one of the most important change agents in our industry? To answer these questions I had the good fortune recently to be able to speak to a select group of top IT industry executives who join...
SQL Injection attacks are one of the easiest ways to hack into a website. One recent hack, using a script from verynx.cn, involves injecting sql into a web form that then appends some JavaScript code into fields in a database that then gets executed on the client side when a user views...
Recursion Software released a private beta version of their Voyager mobile platform, with powerful interoperability for Android, Microsoft .NET and Compact Framework (CF), all Java editions (JME CDC, JSE and JEE), and more than 15 embedded operating systems. The Voyager platform is a p...
2008 is going to be an important year for Rich Internet Applications. Most organizations are delivering or planning to deliver Rich Internet Applications; however, at the same time, most IT managers are facing a dilemma: which Rich Internet Application technology and platform to use? T...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

MOST READ THIS WEEK
ADS BY GOOGLE