Databinding

Chapter 3 discusses databinding Remoting RecordSet results to UI components using ActionScript DataGlue and DataProviderClass objects. Databinding is a powerful technique for streamlining Flash and server application integration.

Most enterprise Java applications encapsulate data access in a layer that hides JDBC code from business application classes. The data access layer accepts and returns business objects instead of JDBC ResultSets, which means that Remoting services in Java usually send collections of objects back to Flash instead of sending ResultSets. Collections of objects in Java become arrays of objects in Flash.

It would be great to be able to databind arrays of objects using DataGlue, just as we do RecordSets. Fortunately, this is quite easy with a class that extends the DataProviderClass implementation, RsDataProviderClass, that comes with the Flash Remoting components. The custom ArrayDataProvider, shown here, extends RsDataProviderClass by defining a constructor that takes an array as an argument and by defining a method, addAll( ), that calls the RsDataProviderClass implementation of addItem( ) to add each object in the array to the data provider:

#include "RsDataProviderClass.as"

_global.ArrayDataProvider = function (list) {
  this.init( );
  this.addAll(list);
};

// ArrayDataProvider subclasses (i.e., extends) RsDataProviderClass. ArrayDataProvider.prototype = new RsDataProviderClass( ); ArrayDataProvider.prototype.addAll = function (list) { if (list ...

Get Flash Remoting: The Definitive Guide 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.