Preface

Four years ago, the authors of this book were looking for a solid platform and a robust component framework to develop rich Internet applications (RIAs) for enterprises. We worked with AJAX. We worked with Java Swing. But when Adobe released the alpha version of Flex 2, we realized that this was exactly what we’d been looking for. To prove our convictions, we even created a company, Farata Systems, dedicated to the creation of enterprise solutions that utilize Adobe Flex on the frontend.

Since then, we have worked on lots of large- and small-scale projects that involved either Adobe Flex or Adobe Integrated Runtime (AIR) technologies. During these years, we have faced recurring issues and have been able to apply the same or similar solutions over and over again. Many solutions involved adding missing features to the user interface (UI) components that came with Flex SDK. In some cases, we had to enhance the communication layer of BlazeDS or LiveCycle Data Services (LCDS). All these enhancements were possible because the Flex framework was well designed as an open framework that allowed customization of its parts that didn’t meet specific needs.

We’ve always shared our findings in the form of technical blogs or articles, but when the amount of accumulated materials reached critical mass, it was clear that the time was ripe for a book targeting enterprise RIA developers and managers.

Having O’Reilly as a publisher of your book is an honor in itself, but you might not know that to get this little “Adobe Developer Library” logo on the cover, our book outline had to get approval from Adobe Flex team members—the most respected software engineers in the field.

Typically, technical books on a particular software include the appropriate version number in the title. This book is different, however; it doesn’t focus on an application programming interface (API) that’s specific to any version of the software. Rather, it explains the approach to efficient design of scalable Flex applications, building component libraries, and dealing with performance issues. Code examples from the book will work in Flex 3 and Flex 4 (in beta at the time of this writing).

The last chapter of the book is dedicated to LCDS 3.0, which was released just before press time and offers a new model-driven approach to developing data-intensive applications. Though the chapter on AIR is based on AIR 1.5, it offers a unique and original solution for data synchronization using AIR and BlazeDS, which will work just fine with AIR 2.0, which, as we write, is currently in beta.

Who Is This Book For?

This book is intended for Flex and Java application architects, team leaders, and senior developers who are interested in getting to know:

  • How the Flex framework works under the hood

  • The pros and cons of some of the third-party libraries

  • How to build reusable component libraries for their enterprises

  • How to select and improve (if need be) Flex-to-Java communication

  • What to watch for from a performance perspective

  • How to modularize the Flex RIA

  • Which design patterns to apply

  • How to select third-party frameworks

This book will be very useful for Java Enterprise Edition (JEE) developers who are still not sure whether the Flex SDK is a good fit for their cross-platform RIAs. We are positive that after reading the first several chapters, you will appreciate the power and flexibility of the open source Flex SDK, third-party libraries, and their server-side tools.

This is not an introductory book, and we assume that the reader already has some experience with developing Flex applications and a good understanding of object-oriented design principles.

How the Book Is Organized

Even though the chapters in this book don’t have to be read in any particular order, in some places we develop code samples or custom components based on materials presented earlier. Following is a brief book outline, from which you can decide your own starting point:

Chapter 1, Comparing Selected Flex Frameworks

The goal of any framework is to make the process of software development and maintenance easier; however, the ways of achieving this goal differ. Some people prefer working with frameworks that are based on the Model-View-Controller (MVC) pattern, and others like dealing with class libraries of components. Each approach has its pros and cons. In this chapter, you’ll learn how to build the same application using the MVC frameworks Cairngorm 2, Mate, and PureMVC. You’ll also see a different, non-MVC approach for generating the code of a create, read, update, and delete (CRUD) application with components from the open source framework Clear Toolkit.

Chapter 2, Selected Design Patterns

Design patterns suggest solutions to common problems that arise during software development. Flex is a domain-specific tool that’s aimed at creating a rich UI for the Web, and in this chapter we’ll discuss the specifics of selected design patterns when applied to the creation of a UI with Flex, namely:

  • Singleton

  • Proxy

  • Mediator

  • Data transfer object

  • AsyncToken

  • Class factory

Chapter , Building an Enterprise Framework

For the majority of the enterprise applications, development comes down to a few major activities:

  • Creating data grids

  • Working with forms

  • Validating data

In this chapter, you’ll learn how to build components for your enterprise framework that simplify dealing with these activities. We’ll identify some of the issues with Flex 3 SDK components and show you how to extend and enhance them.

Chapter 4, Equipping Enterprise Flex Projects

Typical enterprise RIA projects are developed by mixed teams of client- and server-side developers. This chapter is essentially a laundry list of topics that development managers and team leaders face:

  • What skillsets are required for the project

  • How to automate creation of build and deployment scripts

  • What tools to use for testing

  • What continuous integration is

  • How to arrange for logging

  • Which third-party component libraries might come in handy

Chapter 5, Customizing the Messaging Layer of LCDS or BlazeDS

This chapter starts with a quick example of how to perform the push by making a direct call to a MessageBroker, which comes with LCDS and BlazeDS. It continues with a discussion of the existing world of custom adapters and message channels. You’ll see how to implement a messaging layer with guaranteed message delivery and take care of the proper sequencing of messages using BlazeDS implementation of the Action Message Format (AMF) protocol.

Chapter 6, Open Source Networking Solutions

Open sourcing of Flex framework in general, and its communication protocols and server-side components in particular, play an important role in the adoption of Flex by enterprises. Although large-scale applications are most likely powered by LCDS, smaller ones will find open source server-side components very useful. This chapter will unleash the power of AMF and provide illustrations of how to create a robust platform for development of a modern RIA without paying hefty licensing fees. It will discuss polling and server-side push techniques for client-server communications, as well as how to extend the capabilities of BlazeDS. You’ll also learn how to create a BlazeDS-based solution similar to LCDS’s Data Management Services, where you’ll be creating ChangeObject, Assembler, and DAO classes that will take care of automated data synchronization between Flex clients and Java servers.

Chapter 7, Modules, Libraries, Applications, and Portals

This chapter suggests an approach to creating every Flex application as a modularized portal that loads and communicates with independently built and compiled modules and subapplications. You’ll learn how to work with module loaders and the difference between application, child, and sibling domains. We’ll explain how to properly design module-to-module communications. You’ll get familiar with an original technique for compiling Runtime Shared Libraries (RSLs) that are self-initialized, and finally, you will learn how to integrate existing Flex applications as legacy JEE portals.

Chapter 8, Performance Improvement: Selected Topics

This chapter continues the conversation started in Chapter 7. We’ll talk about actual versus perceived performance of RIA and discuss the use of application preloaders to make the first page of your RIA appear as soon as possible. We’ll also describe how to improve the process of initial loading of RSLs, which serves the same goal: minimizing the amount of code that travels from the server to the client computer. You’ll learn how to build every application as a portal while providing an independent testing environment for multideveloper teams. The chapter ends by focusing on issues that affect the performance of most Flex applications.

Chapter 9, Working with Adobe AIR

Adobe AIR is a cross-platform development environment and runtime that adds an API required for desktop applications, comes with a local database management system (DBMS), and substantially simplifies embedding HTML into RIA by offering a full-featured embedded web browser engine. This chapter starts by covering the basics of AIR development, but quickly turns into a project for a fictitious pharmaceutical company that demonstrates a solution for data synchronization between local and remote databases when the network is not always available but the application must remain operational. This solution works with occasionally connected AIR/BlazeDS as well as AIR/LCDS applications. As a bonus, the sample application also demonstrates how to integrate Google Maps into an AIR application.

Chapter 10, Developing Flex Applications for LiveCycle Enterprise Suite

LiveCycle is an service-oriented architecture (SOA) platform that runs on Java EE application servers, and this chapter is about creating enterprise workflows using this tool. You will learn how to use a web browser–based UI written in Flex to streamline the part of the workflow that requires user interaction. We’ll cover the process of extending LiveCycle with your application-specific services and the creation of complex PDF documents. The larger portion of this chapter explains how to integrate LiveCycle ES functionality with your existing Flex-based applications.

Chapter 11, Printing with Flex

Printing is often one of the most time-consuming tasks in developing Flex enterprise applications. Just using the Flex printing API would require allocation of substantial budget and human resources. In this chapter, we’ll discuss an open source solution for generating PDF documents on the client. This printing functionality will be applied to the sample pharmaceutical application introduced in Chapter 9.

Chapter 12, Model-Driven Development with LCDS ES2

In this chapter, you’ll see how to create a CRUD application in which Flex talks to a remote database via recently released LCDS 3.0. The good part is that no programming is required. You’ll create a data model and the rest of the code will be generated automatically.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Note

This icon signifies a tip, suggestion, or general note.

Warning

This icon signifies a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Enterprise Development with Flex, by Yakov Fain, Victor Rasputnis, and Anatole Tartakovsky. Copyright 2010 Yakov Fain, Victor Rasputnis, and Anatole Tartakovsky, 978-0-596-15416-5.” If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at .

The source code for this book is available online; each chapter is in a single zipped folder. To download the sample code for a chapter, enter the directory URL followed by the name of the chapter with the extension .zip. For example, the code for Chapter 5 can be accessed at the following URL:

http://faratasystems.com/entflex_sc/chapter5/chapter5.zip

If you see a directory called Flex4 in some of the .zip files, it contains a port of the Flex 3 code samples. Please note that the folder for Chapter 4 doesn’t exist, as there is no sample code in that chapter. The folder for Chapter 6 doesn’t exist either, because all of the source code for enhanced Flex components is included in the clear.swc library in the Clear Toolkit Concurrent Versions System (CVS) repository at SourceForge. To save space, Chapters 7 and 10 contain only manually written code.

Most of the chapters contain Flex projects copied from the workspaces of the authors of this book. In certain cases, supporting libraries were not included (such as Chapter 8), as some of the projects were more than 300 MB! To use the code in these cases, create a new project in Flash Builder and copy the source code into the newly created project.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:

http://oreilly.com/catalog/9780596154165

To comment or ask technical questions about this book, send email to:

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our website at:

http://oreilly.com

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly.

With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, download chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other time-saving features.

O’Reilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from O’Reilly and other publishers, sign up for free at http://my.safaribooksonline.com.

Acknowledgments

Writing a book requires very serious support from family members, and we’d like to thank them—especially our children, who got used to the idea that after coming home from work, dads still had to be glued to those computers to work on some boring technical book.

We’d like to thank all the members of the Flex community who appreciated our work in the past and encouraged us to continue sharing every little bit of knowledge we’ve gained.

We are grateful to the excellent software engineers from the Adobe Flex team, who put their trust in our ability to write such a complex and advanced book. Our special thanks to one unknown member of the Flex team who allegedly said during the book approval process something like, “I don’t agree with many of the things that these authors write about Flex, and I’d rather not approve them, but I will because there are not many people in the industry who are capable of writing such a book.” We don’t know your name, but we consider this assessment to be the best compliment we’ve received so far.

Our praise goes to the cover designers, who correctly visualized the authors of this book without ever seeing them.

We’d like to thank Aliaksandr Yuzafovich for his research and contribution to the data synchronization solution described in Chapter 9.

Our hats off to Linda Laflamme, an excellent development editor from O’Reilly. After reading some of her comments, we had the feeling that she understands technical materials better than we do.

And mainly, we thank you, our readers, for reading this book.

—Yakov Fain, Victor Rasputnis, and Anatole Tartakovsky

Technical Editor Bios

Kaushik Datta is currently working at Mercedes-Benz USA, LLC, where he and his team have built Flex-based web applications. He has been using Flex since the Beta Royale days. Kaushik spends his off-hours reading blogs on various other Adobe products and looking for better designer–developer workflows. He also enjoys cricket and theater. You can reach him at .

Greg Jastrab is presently a technical project manager at SmartLogic Solutions in Baltimore, MD. He’s been using Flex since version 1.5 and occasionally speaks at local Adobe user groups. Outside of work, Greg enjoys relaxing with his wife and dog, and playing the guitar, video games, and poker. You can follow him at http://blog.smartlogicsolutions.com and on Twitter at @gjastrab.

Igor Lachter is currently a senior developer at SAIC, where he is involved in developing a procurement system using Flex technology. He’s been working with Flex since version 3, utilizing many of the approaches described in this book. When not programming, he tutors SAT math and plays soccer with his three daughters. You can reach him online at .

Get Enterprise Development with Flex now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.