105
ACCESSING DATA WITH FLEX
Accessing server-side data
Last updated 12/3/2012
Primitive values cannot be set to null in Java. When passing Boolean and Number values from the client to a Java
object, Flex interprets
null values as the default values for primitive types; for example, 0 for double, float, long, int,
short, byte, \u0000 for char, and
false for Boolean. Only primitive Java types get default values.
LiveCycle Data Services and BlazeDS handle java.lang.Throwable objects like any other typed object. They are
processed with rules that look for public fields and bean properties, and typed objects are returned to the client. The
rules are like normal bean rules except that they look for getters for read-only properties. This lets you get more
information from a Java exception. If you require legacy behavior for Throwable objects, you can set the
legacy-
throwable property to true on a channel; for more information, see Configuring AMF serialization on a channel.
You can pass strict arrays as parameters to methods that expect an implementation of the java.util.Collection or native
Java Array APIs.
A Java Collection can contain any number of object types, whereas a Java Array requires that entries are the same type
(for example, java.lang.Object[ ], and int[ ]).
LiveCycle Data Services and BlazeDS also convert ActionScript strict arrays to appropriate implementations for
common Collection API interfaces. For example, if an ActionScript strict array is sent to the Java object method
public void addProducts(java.util.Set products), LiveCycle Data Services and BlazeDS convert it to a
java.util.HashSet instance before passing it as a parameter, because HashSet is a suitable implementation of the
java.util.Set interface. Similarly, LiveCycle Data Services and BlazeDS pass an instance of java.util.TreeSet to
parameters typed with the java.util.SortedSet interface.
LiveCycle Data Services and BlazeDS pass an instance of java.util.ArrayList to parameters typed with the java.util.List
interface and any other interface that extends java.util.Collection. Then these types are sent back to the client as
mx.collections.ArrayCollection instances. If you require normal ActionScript arrays to be sent back to the client, you
must set the
legacy-collection element to true in the serialization section of a channel-definition's properties.
For more information, see Configuring AMF serialization on a channel.
Explicitly mapping ActionScript and Java objects
For Java objects that LiveCycle Data Services and BlazeDS do not handle implicitly, values found in public bean
properties with get/set methods and public variables are sent to the client as properties on an 0bject. Private properties,
constants, static properties, read-only properties, and so on are not serialized. For ActionScript objects, public
properties defined with the get/set accessors and public variables are sent to the server.
LiveCycle Data Services and BlazeDS use the standard Java class, java.beans.Introspector, to get property descriptors
for a JavaBean class. It also uses reflection to gather public fields on a class. It uses bean properties in preference to
fields. The Java and ActionScript property names should match. Native Flash Player code determines how
ActionScript classes are introspected on the client.
undefined null null for object, default values for primitives
XML org.w3c.dom.Document org.w3c.dom.Document
XMLDocument
(legacy XML type)
org.w3c.dom.Document org.w3c.dom.Document
You can enable legacy XML support for the XMLDocument type on
any channel defined in the services-config.xml file. This setting is
important only for sending data from the server back to the client; it
controls how org.w3c.dom.Document instances are sent to
ActionScript. For more information, see Configuring AMF
serialization on a channel.
ActionScript type (AMF 3) Deserialization to Java Supported Java type binding