Deep Data Synchronization with BlazeDS

Due to space constraints, you’ve been presented with the simplified fragments of the DataCollection code to highlight its main features and give you a push in the right direction, should you want to create your own version of such a collection. Here are a few more possible approaches that may prove useful.

Note

You can find the complete and up-to-date source code of the DataCollection class (900+ lines of code) in the SourceForge repository.

Nested DataCollections

Previously, you learned about data synchronization between DataCollection and remote Java objects via the method sync(). But what if you have a situation with nested DataCollection objects that can be modified on the client side? How do you synchronize the changes in this case? Here’s the magic line of code that will perform deep synchronization of the DataCollection and all its nested children:

collection.sync(true);

If you don’t like manual coding, Clear Data Builder will perform deep synchronization of hierarchical DataCollections with the server, so that if an item of the collection contains child collections (Example 6-16, shown later), the entire tree of changes gets synchronized with the Java backend in one transaction.

Consider a sample order-processing application (Figure 6-7) that allows the user to navigate from order to order, editing the master information (order) as well as its details (order items).

Figure 6-7. The order-processing application

The user can modify either of the ...

Get Agile Enterprise Application 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.