Adobe/Macromedia Flex takes you to the next level of web application development with the concept of Rich Internet Applications (aka RIAs). You may have seen applications developed natively in Flash itself and realized that it offers a much more robust experience for the user where productivity is bolstered by ease of use, streamlined workflow, and real time interactivity that is impossible to accomplish in HTML itself. However developing rich applications in Flash for those who are core developers is daunting and unintuitive. The Flash development tool is geared for designers, and developing on a timeline is a strange concept. Flex removes that barrier to entry by providing a programmatic way for developing these RIAs.
Rich Internet Applications
What is an RIA anyways? Well HTML applications are state-less. Application servers maintain state by using cookies and session variables to keep track of users, but all the logic is on the server. So while a user is looking at a page in their browser, the application is unable to do anything until the user commits an action that sends data from the page back to the server for processing. The code processes the data, and generates resulting HTML that the browser loads back in.
A simple example would be a report or search tool that queries a sales/CRM database based on various criteria from the user such as deal time frame, product group, and sales executive. The user enters these values, clicks on a submit button, and the browser goes blank while it waits for a response from the server and loads the resulting HTML which would be a tabular list of records that match the criteria:
Time Frame From To Product Group
|Deal Initiated||Product Group||Product||Sales Exec||Value ($)|
Look familiar to anything you've done? Now if the user wants to change the parameters, or perhaps sort on a particular column, typically the page would need to be sent back to the server where it rebuilds an up to date report based on the new criteria. Pretty standard stuff for Coldfusion, JSP, PHP, ASP, or any other servlet language.
In the Flex world, your application wouldn't need to post a request to the server every time the user made a change. Instead of the logic living purely on the server side, your presentation tier is all on the client. So imagine changing filters or criteria, and the table automatically updating as a result. Imagine clicking on a column title and the column automatically sorts without reloading the page. This saves hits to your web server, application server, database, and network. For one user this may not be a big deal, but what about 1000 users, or 10 000 users?
HTML based applications are a series of HTML web pages; Flex applications are LIVE applications. A simple analogy is imagine Word or Excel being an HTML web application; vs the real application itself. It could be done; but the real application is aware of your mouse movements, every key stroke, and provides much more feedback to the user by using sound, animation, and other visual queues.
Even better, with the Flash Player penetration near 99% (version 7 is at 83%) you can provide this real-time rich experience on Unix, Windows, and MAC. Alternatively any richness you try to accomplish in IE using DCOM, ActiveX, and DHTML locks you down to particular platforms.
Flex vs Coldfusion (and other servlets)
For CFMX developers, Flex doesn't replace CF (or JSP/J2EE/PHP/ASP/etc…). It's a companion to your existing technology by being at the presentation tier, while your other Application servers provide the middle/business tier. It lets you focus on the client workflow, and not waste time building HTML tables and endless cosmetic logic.
I put together a simple example that demonstrates this, which you can download here. The attached file provides a static XML file; but you easily hook it up to a CF template which queries a database based on the parameters passed in via the URL and return back the up to date HTML.
The first example which uses Coldfusion:
It does a CFHTTP to the XML provider by passing in the sort direction parameters based on what column a user clicked on. After parsing the XML, it loops through the XML array with some basic styling to do alternating row colors. It's roughly 40 lines or so, depending on how compact or readable you want to make your code.
The second example which uses Flex:
Since my web hosting company doesn't provide Flex hosting I can only provide screen captures. The Flex version retrieves the exact same XML content as the Coldfusion one would. However the key notes to make in the above example are: