Exposes a remote service.
Syntax
<xe:jsonRpcService attributes>content</xe:jsonRpcService>
Table 1. Essential properties
Property |
Description |
id |
Defaults to jsonRpcService1 , jsonRpcService2 ,
and so on. |
pathInfo |
Identifies the location of the service
relative to the XPage. |
serviceName |
Name of a client-side JavaScript service.
Overrides pathInfo. |
methods |
Specifies remote methods provided by
a service. |
Examples
This example exposes a remote service
then uses a button with a client-side script to call a service method
and redirect its JSON output to the local file system.<xe:jsonRpcService id="jsonRpcService1" serviceName="userinfo">
<xe:this.methods>
<xe:remoteMethod name="getUserName">
<xe:this.script><![CDATA[return @UserName()]]></xe:this.script>
</xe:remoteMethod>
<xe:remoteMethod name="add" script="return arg1 + arg2">
<xe:this.arguments>
<xe:remoteMethodArg name="arg1"></xe:remoteMethodArg>
<xe:remoteMethodArg name="arg2"></xe:remoteMethodArg>
</xe:this.arguments>
</xe:remoteMethod>
</xe:this.methods>
</xe:jsonRpcService>
<xp:button value="Display the user" id="button3">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[var deferred = userinfo.getUserName()
deferred.addCallback(function(result) {
alert(result)
});]]>
</xp:this.script>
</xp:eventHandler>
</xp:button>