Over a million developers have joined DZone.

Calling Flex Data Services from Pivot

DZone's Guide to

Calling Flex Data Services from Pivot

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

Pivot comes with built-in support for calling JSON-based REST services. However, if you prefer a more RPC-oriented approach to interacting with server-side data, Adobe's BlazeDS is now a great alternative. BlazeDS is an open-source implementation of the Flex RPC protocol, called AMF (short for Action Message Format). Adobe has begun including Java client libraries in recent builds of BlazeDS, making this protocol available to Pivot applications, which are written in Java.

Documentation on the Java AMF client API is scarce, but I was able to get a prototype up and running relatively quickly. The relevant source code is shown below; the full source is available here:

AMFConnection amfConnection = new AMFConnection();
String url = "http://localhost:8080/samples/messagebroker/amf";

Object result = null;
try {
result = amfConnection.call("product.getProducts");
java.util.ArrayList<object> products = (java.util.ArrayList<object>)result;
productTableView.setTableData(new ListAdapter<object>(products));
} catch(Exception exception) {
} finally {

The application creates an instance of AMFConnection and calls the getProducts() method of the "product" service. This method returns an array list of Product instances that will be displayed in the table. See the samples included with the BlazeDS distribution for more information on how the service is defined.

The returned array list is wrapped in a Pivot ListAdapter and set as the table data. The result looks like this:

For comparison, here is a screen shot of the original Flex example:

So, in addition to REST, Pivot now also has a simple and lightweight means of invoking RPC-oriented web services via BlazeDS, which opens up a number of additional possibilities for Pivot developers.

From http://pivot-toolkit.org/demos/pivot_amf.html

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. 


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}