djna
djna

Reputation: 55957

worklight 6.2 native api adapter invocation

In JavaScript my Worklight Client can pass arbitrary objects to an adapter:

var payload = { able: 3488, baker: "wibble"};

var invocationData = {
    adapter : 'xxx',
    procedure : 'xxx',
    parameters : [payload],
    compressResponse : false
};

var options = {
        onSuccess: onCallSuccess,
        onFailure: onCallFailure    
};

WL.Client.invokeProcedure(invocationData, options);

and the adapter can access the object

 function xxx(p1) {  
      return {'answer': p1.able};
 }

In the native APIs it seems that we are limited to primitive types:

public void setParameters(java.lang.Object[] parameters)

This method sets the request parameters. The order of the object in the array will be the order sending them to the adapter

Parameters: Object - parameters An array of objects of primitive types ( String, Integer, Float, Boolean, Double). The order of the objects in the array is the order in which they are sent to the adapter.

Hence if my adapters are to be used by both JavaScript and Native clients they will need to accept any complex objects as JSON Strings. Unless there is an alternative I'm missing?

Upvotes: 0

Views: 194

Answers (1)

Namfo
Namfo

Reputation: 301

I don't see a better alternative than simply stringifying the object as you have suggested. Are you using objects other than JSON in your native side? If so what is the structure of the object?

Upvotes: 1

Related Questions