The ActionScript client library’s RestClientHelper
class includes the following helper methods, which convert arrays, Lists, and Objects to Multivalue
objects:
public static function convertArrayToMultivalue(pValue:Array, pMultiValueType: String, pComponentType:String, pFormat:String, pSession:RestSession):String public static function convertIListToMultivalue(pValue:IList, pMultiValueType: String, pComponentType:String, pFormat:String, pSession:RestSession):String public static function convertObjectToMultivalue(pValue:Object, pMultiValueType: String, pKeyType:String, pValueType:String, pFormat:String, pSession:RestSession): String
The following table describes the arguments for each of these methods.
Argument | Description |
---|---|
| The absolute path of a Java class, such as |
| The class type of the component to instantiate for each element in the multivalve type. For example, an array of integers in ActionScript could be converted to an |
| The server’s input format type. This can be retrieved from the session object’s |
| ActionScript objects act as associative arrays (similar to java Maps), the These arguments are similar to |
Similar to the Java client library, passing arguments to methods is generally straightforward. For primitive types, just add them to the pArguments
array.
var result:RestResult = RestComponentHelper.executeMethod("/some/Component", "aMethod", [1,2,3,4.4,5.5,true,'a',0xa], null, session, handleResult, handleFault)
To pass a reference to a repository item, use the format
<repository path:item descriptor name:item id>
For example:
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", ["/atg/commerce/catalog/ProductCatalog:product:prod12345"], null, session, handleResult, handleFault)
To pass a reference to a Nucleus component, pass the Nucleus component path. For example:
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", ["/atg/dynamo/Configuration"], null, session, handleResult, handleFault)
The following example is a call to a method which takes a repository item array and a GenericService
array.
<programlisting> var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [["/atg/commerce/catalog/ProductCatalog:product:prod12345", "/atg/commerce/catalog/ProductCatalog:product:prod67890"], ["/atg/dynamo/Configuration","/atg/dynamo/Configuration"]], null, session, handleResult, handleFault)
As mentioned above, arrays, ILists, and Objects must be converted before being passed to the server. The following example demonstrate passing an array using the helper methods in the RestClientUtils
class.
var arrayCollection:ArrayCollection = new ArrayCollection(["abc","def"]); var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [RestClientUtils.convertIListToMultivalue(arrayCollection, "java.util.ArrayList", "java.lang.String", RestConstants.JSON, session)], null, session, handleResult, handleFault);
The following example, which calls executeMethod()
, produces the same result as the previous example:
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", ["java.util.ArrayList:java.lang.String:[\"abc\",\"def\"]"], null, session, handleResult, handleFault)
The following examples use the helper methods in the RestClientUtils
class.
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [RestClientUtils.convertArrayToMultivalue(["abc","def"], "java.util.HashSet", "java.lang.String", RestConstants.JSON, session)], null, session, handleResult, handleFault) var obj:Object = new Object(); obj["abc"] = 123; obj["def"] = 456; var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [RestClientUtils.convertObjectToMultivalue(obj, "java.util.HashMap", "java.lang.String", "java.lang.Integer", RestConstants.JSON, session)], null, session, handleResult, handleFault)