7.8. Managed Entities for Flex Applications

So far, the integration discussion has hovered around persistent objects transmission across the layers. Effective proxy management and lazy loading have been touted as the clear winning features. However, that may not be all that a complex business application desires. More often than not, what is required are managed data objects and entities.

Managed data sets are not new to Flex. LCDS supports them. A few open source Flex and Java projects also incorporate this idea in their approach to business problem solutions. However, there is still open debate on its applicability and its merits. Some in the community swear by it; others consider it an unnecessary overhead.

So, what exactly are managed entities and how do they differ from regular data access patterns in Flex? How can you include them in BlazeDS and where does JPA or Hibernate come in within this context? The answers to these questions is the content of this section.

Many a Flex application fetches a data collection from the server and allows CRUD operations on such a collection. In traditional hand-coded applications, each of the CRUD operations is passed down to the server and managed through custom service methods, which in turn call the persistence layer functions to make the modifications permanent. Sometimes, these service methods resort to invoking SQL statements on data stores and manipulating the result sets, which is certainly something that should be avoided in most situations.

With JPA and Hibernate, managing CRUD operations on the server side is easy. What you need is a service layer that provides a common API and a point of interception for the CRUD operation calls. LCDS implements data management using the concept of a ChangeObject, where it keeps track of the current or changed values and the previous value. Depending on the type of CRUD operation, appropriate action is taken and conflicts, if any, are managed. The ChangeObject interface can be looked up in the LCDS documents at http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcdsjavadoc/flex/data/ChangeObject.html. From the Flex client perspective, collections have a simple contract with only two main methods, commonly named fill and sync. The fill method reads or gets a collection and the sync method implements any of the CUD methods of the CRUD set. As of now, there is no fully integrated Java, BlazeDS, and Hibernate–based open source product that provides such a solution. Efforts have begun to create such a solution. The project is called Usable, and you can keep track of it at the initiative's project site: http://code.google.com/p/usable.

The open source Clear Toolkit (http://sourceforge.net/projects/cleartoolkit/) is a possible alternative. It has a library of Flex components that includes a DataCollection class that supports Managed objects. It works with Flex, Java, and BlazeDS applications. Support for Hibernate on the server side can be manually hooked up if needed.

Another alternative for a managed CRUD solution using Flex and Hibernate with BlazeDS exists in the Grails Flex Scaffold (GFS) project. The project web site is www.grails.org/plugin/flex-scaffold. GFS is a grails plug-in that generates Flex scaffolding code and includes support for presentation and service layers by providing embedded data in your domain classes. It leverages BlazeDS.

Chapter 11 will revisit this topic and deal with it in detail. However, for now it's time to wrap up and then move on to testing and debugging BlazeDS-based Flex applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.176.145