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

ColdFusion: Article

Developing Flex 2 Applications with ColdFusion and XML Without Needing FDS or Mystic

Solutions for the low-budget developer using HTTP services

Flex is one of the greatest technologies around. Combine it with ColdFusion and it just gets better. Adobe has made it possible to use Flex 2 efficiently with ColdFusion and easily get data across the server to a Flex front-end.

It's also released Flex data services that don't need ColdFusion to pass data in and out. However, these technologies might be outside the price range of a small developer or hard to deploy. Take FDS, for example. Of course Adobe has an Express edition, but deploying a good application for all the world to see hosted on your own computer is a hassle, and if you were to go out and look for a host that supports FDS it would cost you about $360 a year. Not a lot for some, but for an individual developer who's already paying for a solid ColdFusion host, it may be too much. Another technology that Adobe introduced was an update to Flash remoting in ColdFusion 7.0.2, yet most hosting providers won't support Flex connectivity on their servers, and again you'd have to buy a VPS, which would cost you $360 a year. Nevertheless, in the world of dynamic technology there are other alternatives. And ColdFusion-generated XML or what some might consider HTTP services is one of them. This is an easy way to get data from your MySQL, Access, and Oracle database and bring it into Flex, read it, update it, and if you want even delete records based on the user level. This article will discuss the basics of using this method, teach you how to build ColdFusion-based XML files, and bring them in and explain how you can use them in your Flex application.

The Background
Using XML as a data delivery source has been around since the dawn of Web 2.0 or before. Almost all Web 2.0 Web sites use XML as a method of delivering news using RSS to their users. Although this is a good way to use XML there are better ways. Instead of transporting news in XML what if you can transport the user data and authentication. Many sites such as Flickr and Blogger have an API that lets you to do this and, in fact, this is a good solution. Rather than getting FDS to retrieve data, we just encapsulate the data in an XML file that in turn is read by Flex and displayed. No Mystic, No FDS, just plain ColdFusion, XML, and Flex.

Why Use This Method over WSDLs, FDS, or Mystic?
There are different ways of getting data from a database and bringing it into your front-end like Web Services (WSDL). However, not a lot of developers who are starting off know how to create a WSDL or they don't have the time to learn how. Using ColdFusion-generated XML basically means creating a query and outputting it through some XML and cfloops. Any ColdFusion developer who is starting off can quickly harness this power and create applications in record time. After all, developing applications that are in demand is a race. Using this method is not restricted to Flex applications, you can create an application in virtually any modern programming language without modifying a single line of back-end ColdFusion code. How? Well, because XML is read, as I said, by any modern programming language, all you have to do is "hook up" the XML to the front-end via an HTTP service call. The application we're going to build in this article makes use of the HTTP service call rather than a Web Service call, and gets all the data back from the server and then the user can manipulate the data.

Another great reason to use this type of programming method is because you can "open" the back-end files or give the links to developers who are masters in their own field who can then develop third-party front-ends using your back-end. This can extend the reach of your site and deliver your data to more people, and will entice developers into creating mashups, where they take your data and using another API (as this is called) mash them up to create one heck of an application. An example would be if your application was a user-based contact manager, and after opening the API to developers, they could take the data and mash it into Google maps, where when you click on the contact it will show where the house is based on the ZIP code.

Time to Build Your Own Application
This isn't your boring old computer science class where all you did was learn theory and learn and learn. As a result instead of telling you more about this type of programming, why not just dive in and learn on the way. The Flex 2 application we're going to build will be an RSS manager, which will have user authentication and a place to keep and read all your favorite RSS feeds. (See Figure 1 for the final application.)

What we're going to create is a bunch of objects that will interact with the Flex application via an HTTP service call and then interact with the database via a cfquery. It will be a learning experience. You'll learn the basics of a Flex application and HTTP services. Also since we're not building a sophisticated application, we're not going to have Flex do the authentication. We'll leave that to ColdFusion simply because it's too hard and will take a lot of time otherwise. What this means is that even if the username/password combination is wrong, Flex will let the user pass through to the next step but there will be no data in the data grid.

It's possible to let Flex do the authentication, but this is just a proof-of-concept application, not a "real-world" one. What I hope is that you learn a little more about this method and then you can build on it however you want.

Getting the Tools
Since this is for the individual developer who wants to make the most out of a small budget, we'll be using tools that are completely free. The first thing you should do is go and download ColdFusion, which you should already have anyway. Next you'll want to downlaod the Eclipse platform along with CFECLIPSE (all the links are at the end of this article), which is a good ColdFusion IDE for coding, not designing. Seeing as how we're going to use ColdFusion just for coding CFECLIPSE is the way to go.

Next you'll want to download the Flex Builder and read up on the compiling instructions since this will be your tool to compile Flex applictions into Swfs that can be run on virtually any server. Yes, there is the free version of Flex 2 called the Flex 2 SDK However, Flex Builder 2 is more enchancing and will make coding a whole lot easier. I recommend that you download Flex Builder 2. In addition you'll also want to download a database technology such as MySQL or Oracle and create a DSN in the ColdFusion Administrator.

Architecting the Database
After that it's good practice to lay out your database first and create all the required tables. This way you can build your Flex 2 application and the ColdFusion code relying on the database rather than making guesses on the tables you'll create. So create a new DSN in the CF Admin named global since all the example code uses this DSN. There will be two tables in this simple application that we're going to create. The first will be a user table that will hold all our user data. It will also add the values Faisal, Faisal (user, pass) and the values Abid, Abid (user, pass). If you want, you can add more, but this application is just a concept application. If you're using MySQL as a database then here's the code:

CREATE TABLE 'CFDJ_users' (
    'member_ID' int(11) NOT NULL auto_increment,
    'Username' varchar(255) NOT NULL,
    'Password' varchar(255) NOT NULL,
    PRIMARY KEY ('member_ID')
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO 'CFDJ_users' VALUES (1, 'Faisal', 'Faisal');
INSERT INTO 'CFDJ_users' VALUES (2, 'Abid', 'Abid');

Then you'll want to create your RSS table. In this table the user will post a link for an RSS feed and a name to go with it, so the user can come back days later and click on the link and get the feed delivered instantly. You're going to need just four fields for this: an RSS ID field that will be your primary, a username field, an RSS link field, and last an RSS name field. If you did this in MySQL here is the code:

CREATE TABLE 'CFDJ_RSS' (
'Rss_ID' INT NOT NULL AUTO_INCREMENT ,
'Username' VARCHAR( 255 ) NOT NULL ,
'Rss_Name' VARCHAR( 255 ) NOT NULL ,
'Rss_Link' VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( 'Rss_ID' )
);


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.

Comments (1) 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
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

@ThingsExpo Stories
When growing capacity and power in the data center, the architectural trade-offs between server scale-up vs. scale-out continue to be debated. Both approaches are valid: scale-out adds multiple, smaller servers running in a distributed computing model, while scale-up adds fewer, more powerful servers that are capable of running larger workloads. It’s worth noting that there are additional, unique advantages that scale-up architectures offer. One big advantage is large memory and compute capacity...
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
No hype cycles or predictions of zillions of things here. IoT is big. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, Associate Partner at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He discussed the evaluation of communication standards and IoT messaging protocols, data analytics considerations, edge-to-cloud tec...
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), provided an overview of various initiatives to certify the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldwide re...
The Internet giants are fully embracing AI. All the services they offer to their customers are aimed at drawing a map of the world with the data they get. The AIs from these companies are used to build disruptive approaches that cannot be used by established enterprises, which are threatened by these disruptions. However, most leaders underestimate the effect this will have on their businesses. In his session at 21st Cloud Expo, Rene Buest, Director Market Research & Technology Evangelism at Ara...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.