リモートサービスを公開します。
カテゴリ
データアクセス
構文
<xe:jsonRpcService attributes>content</xe:jsonRpcService>
表 1. 必須プロパティプロパティ |
説明 |
id |
デフォルトは jsonRpcService1、jsonRpcService2 などです。 |
pathInfo |
XPage を基準としたサービスのロケーションを識別します。 |
serviceName |
クライアントサイド JavaScript サービスの名前。
pathInfo を上書きします。 |
methods |
サービスによって提供されるリモートメソッドを指定します。 |
例
以下の例は、リモートサービスを公開した後、クライアントサイドのスクリプトを使用したボタンを使用してサービスメソッドを呼び出し、その JSON 出力をローカルファイルシステムにリダイレクトします。
<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>