| By Faisal Abid | Article Rating: |
|
| October 10, 2006 12:00 PM EDT | Reads: |
22,443 |
Writing ColdFusion to XML Translation
The next
step is to write the middle tier, the ColdFusion code that will
generate valid XML depending on the data in the database. We're going
to want to create five CFM files that will be called in our HTTP
service tag. Why five you ask, and not one WSDL. Well, because we're
exploring HTTP services. In Flex you won't be able to call on a Web
Service inside an HTTP service tag. If you've ever used the Flickr API,
you may have noticed that there's one root URL with different sub-URLs
that do different things. This is just an example; don't take this URL
seriously. With Flickr.com/get.cfm?tag=32, you can clearly see that you
can't get anything more from that URL than just the tags. However,
Flickr has a whole range of other methods like SOAP and XML-RPC that
will let you to do much more. Nevertheless, since we're doing it the
HTTP call way, why not take a step-by-step process to write up these
CFM files. You can surely apply these techniques in creating a WSDL.
We're not going to have registration capabilities in our application,
since it's a simple proof-of-concept application, but if you go to Listing 2 you'll see a register.cfm file you can use if you want registration capabilities.
Login.cfm
The next step is to actually let users
use the login.cfm file. Since we've already covered the basics of the
code in the Register.CFM section, we'll briefly explain what's happing
here and you can see the completed code in Listing 2. First, ColdFusion
is checking whether the variables defined in the URL exist in the
database or not, and if they don't ColdFusion generates an XML message.
However, if the username and password exist then ColdFusion generates a
successful message and gets all the feeds in the database attached to
the username.
RSS Manager Vitals
Since we're building an RSS
manager, it would be useless if we just had an RSS reader. So we're
going to quickly write two files, which add and read the RSS feed. We
have to build a reader in ColdFusion first. Because of Flash Player
sandbox security issues, it won't go directly to the site and read it,
instead ColdFusion will be the delivery boy that will go and get the
feed and pass it locally to the Flash player. Building the Flex
Front-End (For the final code see Listing 5)
The foundation of this Flex application relies on the CFM files you created in the previous steps; you'll call these files via HTTP services, and hook up the results to the data grids. Since this explores some topics that were in the intermediate group you should already know how to hook up files and create data grids and so on. I won't walk through the application step-by-step. But I will outline of what's happening in the application.
First, when you load the application in the browser, you'll be prompted with a username and password field. When you insert the right username and password it will make an HTTP call to the login.cfm file with the user and password, and change the state to "feed." If the username and password were successful, you'll be able to add a feed and read it; however, if it wasn't, you'll still be able to go the feed state but won't be able to add or read any feeds.
When you click "add feed," you'll be taken to a new 'add' state that will have a feed name, feed URL field, and save button. Then you'll make a new HTTP call to the file WriteRSS.cfm and add a click handler for the button that will call the WriteRSS.cfm and the login.cfm files so that the data grid refreshes.
Last you'll create your last HTTP call to the ViewRSS.cfm file and you'll add it to the feed URL scope so that it will read the selected item (link) of the data grid that gets all your feeds in the database and then hooks that service to a new data grid. What's going on is that when you click the first data grid, it populates the second data grid with the news from the URL. You'll also create a new text area that will get the description of the selected item in the second data grid, so that when you click on the second data grid it will get the news in the text area.
Well, that's about it for the Flex application. It was simple to build, but with a lot of functionality. As I said before, you can add the register.cfm and make it so that you have to register before you have to use it. You can also add transitions, effects, and cool skins to make your Flex application look pretty. Flex is a technology that is just being discovered, it will soon become the ultimate way to build rich Internet applications and with a growing community it will be as easy to learn as your ABCs.
Links
Published October 10, 2006 Reads 22,443
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Faisal Abid
Faisal Abid is a third-year student at West Hill CI and loves Flex, ColdFusion, and rich Internet applications. He is also the founder and owner of G-uniX Technologies (www.G-uniX.com), an RIA software development consultancy based in Toronto that specializes in Flex 2 and ColdFusion applications. He has a blog at blog.G-uniX.com that he updates bi-weekly with G-uniX news, Flex tutorials, ColdFusion tutorials, and Spry tutorials.
![]() |
shawn gibson 02/21/07 06:42:51 AM EST | |||
Trying to get this running but I get the following errors in Flex: The reference to entity "Pword" must end with the ';' delimiter. ...any idea what that means? I comment it out, and the same error appears for all the HTTPService lines. Shawn |
||||
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Adobe Cans Another 9% of its Workforce
- Moyea DVD4Web Converter V2.0 Converts DVD to FLV Fast and Synchronously with Watermarks
- Adobe Fiddles with its Web Apps
- Adobe & Salesforce Cut Cloud Deal
- Hosting.com Launches ColdFusion 9 in the Cloud
- The Real Time Infrastructure Ultimatum
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Microsoft Expression Web Has Got Game
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Adobe Flex Developer Earns $100K in New York City
- Bruce Chizen Joins Voyager Capital as Venture Partner
- My Top Seven Wishes From Adobe MAX 2009
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Web Services Using ColdFusion and Apache CXF



























