|
Comments
|
Today's Top SOA Links
BF on CF On ColdFusion and Flex
What Flex can do for you
By: Ben Forta
May. 11, 2004 12:00 AM
Macromedia Flex is a brand new server product, one that is poised to forever change the way we coders think about building rich and engaging user interfaces. Yes, I did say "server." No, Flex does not compete with ColdFusion. Yes, Flex and ColdFusion are designed to work together. Having now dispensed with the obligatory preliminaries, I'd like to present Macromedia Flex to the ColdFusion audience from a distinctly ColdFusion angle. And so this month I will:
The best way to understand Flex is to think about how you build Web applications right now. If you are a ColdFusion developer (or a developer who uses ASP, JSP, PHP, and the like) you probably build applications comprised of lots of linked pages. These pages contain client code (at a minimum, HTML and JavaScript) as well as server-side code (CFML, SQL, and so forth). You probably try to separate content (or back-end data) from presentation (the front-end UI), but you still use both to create your application. So, in the case of a ColdFusion page, a browser requests a CFML file, ColdFusion parses and processes the CFML in that file, and then returns client code to the browser. The browser renders the client code on the client, but it is ColdFusion on the server that embeds that client code in the page. Put differently, ColdFusion is a server that dynamically generates client-side code. So why all this analysis? Simply put, Flex works in much the same way. Whereas ColdFusion (despite being somewhat client independent and agnostic) generates client-side HTML, Flex generates client-side Macromedia Flash SWF files. Perhaps that's a bit too simplistic, but the analogy is sound: ColdFusion uses plain text files containing CFML tags to render browser content, and Flex uses text files containing MXML tags to render Macromedia Flash content. Compare the flows of both processes in Figures 1 and 2. But that is where the similarities end. Unlike ColdFusion, Flex and its language, MXML, do not provide tags for database integration, sending and receiving e-mail, connecting to LDAP servers, or creating Web services. Whereas ColdFusion is more of an all-purpose application development platform, Flex has a far more focused objective and a very specific goal. Flex is designed to facilitate the creation of rich and engaging presentation layers, letting developers create well designed and optimally architected n-tier applications that adhere to standards and best practices. With Flex, coders can take advantage of the ubiquitous Flash platform from a very code-centric starting point, but what Flex generates is still Flash content. In other words, Flex is all about presentation and user interaction, and that's it. Flex is actually similar to ColdFusion in one other way. Flex, like ColdFusion, is a Java application. Flex is deployed on top of standard J2EE servers, such as Macromedia JRun, IBM WebSphere, and so forth, in much the same way that you deploy ColdFusion, but more on that soon. All of the previous discussion means that Flex does not compete with ColdFusion; rather, Flex needs ColdFusion (or Java, or .NET, or something, anything, providing back-end integration). A Flex application needs a back end, and that back end can indeed be ColdFusion (as in Figure 2). How do ColdFusion and Flex interact? The answer is that it depends. There are two distinct ways to go about using them together. ColdFusion As a Flex Back End
At this point, ColdFusion/Flash integration becomes obvious, Flex calls ColdFusion pages via HTTP requests, or invokes ColdFusion components (CFCs) as Web services. You can use any ColdFusion code that you can invoke through HTTP or as a Web service within Flex applications. To do this, you don't even have to have ColdFusion installed on the same server as Flex, although that configuration works too. In Figure 3, the flow works something like this:
This integration is also ideal for applications with multiple presentation layers. For example, if you needed a straight HTML version of your application in addition to the more engaging Flex version, you could simply provide multiple presentation interfaces to your back-end code. You would put your application logic, without any UI at all, in ColdFusion components; CFML pages would invoke the CFCs and render the HTML version of the application; and Flex MXML pages would render the Flash version of the application. The bonus is that both use the same back-end code. ColdFusion-Generated Flex Can you use ColdFusion to dynamically generate Flash apps in much the same way as it can HTML? Yes, you can, through the Flex JSP Tag Library interface. Flex comes with JSP tags that you can use inside of JSP pages. JSP tags are much like CFML tags, except that they are written in JSP instead of in CFML. With Flex JSP tags, developers programmatically embed Flex tags such as the Tree tags or the Grid tag in their JSP pages so that when a user requests a JSP URL, the generated page has Flash embedded within it. How does this help ColdFusion developers? ColdFusion code can call JSP tags too. CFML has a tag named <CFIMPORT> that developers use to import or include JSP tags; once imported, developers can use these tags like any other ColdFusion tag. To be able to do this, ColdFusion and Flex must be installed on the same J2EE server. While this installation process is not terribly difficult, it's a manual process. This obviously requires ColdFusion Enterprise, and will not work with a Standalone ColdFusion installation, since the Standalone ColdFusion installation does not expose a J2EE server that could run Flex. Figure 4 shows the workflow:
Where to Use Flex
Of course, these are high-level generalizations, and there is no hard-and-fast rule here. The key is that Flex empowers developers to build rich and highly interactive user experiences. It is best suited for applications where this type of interaction is a requirement and where the project plan can accommodate the overhead associated with this type of experience. In case I did not state this clearly enough, Flex does not replace Flash. In fact, almost anything that can be done in Flex can be done in Flash too; the major difference is the development model (including code management, the use of design patterns and best practices, team development, versioning and editioning, and more). As a Macromedia developer, you now have one more weapon in your arsenal. Where to Go from Here In addition to overviews, positioning, and technical content, you'll also find practical and honest discussions on Flex itself to help you determine if it is right for you and your projects. Macromedia wants to help you build a better user experience, and that may involve Flash, it may involve Flex, and it may involve both. Whatever it is, we'll help you get there. Conclusion Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||