methods - Methods

Specifies remote methods provided by a service.

Category

other

Syntax

<xe:this.methods>
	<xe:remoteMethod attributes>content</xe:remoteMethod>
	...
</xe:this.methods>
Each remoteMethod object has the following properties:
Table 1. Essential properties
Property Description
arguments - Argument List List of remoteMethodArg objects passed to the method. Each object has the following properties:
  • loaded - Loaded
  • name - Argument Name
  • type - Argument Type
loaded - Loaded Whether the tag instance is created when the page is loaded. True or false.
name - Method Name Name of the method.
script - Script A server-side script.

Usage

In Design mode, click All Properties and look for methods under other.

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()]]&gt;</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>