0
votes

I have set up a jsonRPC service:

<xe:jsonRpcService id="jsonRpcServiceKeywords"
        serviceName="rpcServiceKey" rendered="true">
        <xe:this.methods>
            <xe:remoteMethod name="getKeyWordalias">
                <xe:this.arguments>
                    <xe:remoteMethodArg name="key" type="string" />
                </xe:this.arguments>
                <xe:this.script><![CDATA[var values = getKeywordAliasValues("matterStatus",key);
return values;]]></xe:this.script>
            </xe:remoteMethod>
        </xe:this.methods>
    </xe:jsonRpcService>

The function getKeywordAliasValues returns an SSJS array.

function getKeywordAliasValues(key,values){
var aliasValues = new Array();
// routine to add values to array
return aliasValues;
    }

When I call the service frpm client-side javaScript:

var alias = rpcServiceKey.getKeyWordalias("10");
alert(alias)
alert(alias[0])

I get first an object returned. Second the message undefined.

Print statements in my SSJS function confirm that the array contains values.

I assume the SSJS array must be converted to a CSJS array. How must I do this?

1
use the dev tools network view to check, what the actual response looks like in the http traffic.umeli

1 Answers

0
votes

I've not used JsonRPCService much, but I think the best option will be to return JSON. I'm not sure if it needs a JSON object or whether a JSON array will work. If a JSON array is enough, the best method in Domino will be to use com.ibm.commons.util.io.json.JsonJavaArray. This can take a Java List or an object in its constructor, so com.ibm.commons.util.io.json.JsonJavaArray jja = new com.ibm.commons.util.io.json.JsonJavaArray(myArray). Because it's SSJS you'll need to either import the package or use the full hierarchical name. It may not be designed to handle an SSJS array, depending how that converts in Java. If you wish to replace the SSJS array with just JsonJavaArray, once created as a blank array it works like a Java list.