Author: lou
Date: 2008-03-24 08:57:54 -0700 (Mon, 24 Mar 2008)
New Revision: 8369
Modified:
openlaszlo/trunk/lps/components/rpc/rpc.lzx
Log:
Change 20080324-lou-O by [EMAIL PROTECTED] on 2008-03-24 11:45:59 AST
in /Users/lou/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: fix reference page problems for rpc, param, and remotecall
Bugs Fixed: LPP-5651, LPP-5652, LPP-5621 (partial)
Technical Reviewer: (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Details:
for all, add introductory paragraphs and code examples that were in r3.4
5652 (remotecall) add return type and value for method invoke()
5621 (rpc) is still missing attributes onload and onunload that were in 3.4
Tests: visual verify
Modified: openlaszlo/trunk/lps/components/rpc/rpc.lzx
===================================================================
--- openlaszlo/trunk/lps/components/rpc/rpc.lzx 2008-03-24 15:57:02 UTC (rev
8368)
+++ openlaszlo/trunk/lps/components/rpc/rpc.lzx 2008-03-24 15:57:54 UTC (rev
8369)
@@ -184,54 +184,119 @@
rpc passes in an empty array.</p>
<example title="Invoking remote function using proxy function
stub">
- <canvas debug="true" height="280">
-
- <debug x="10" y="40" width="470" height="230" />
-
- <soap name="temperature" autoload="false"
-
wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
-
- <method name="init">
- super.init();
- Debug.write('soap service loading...');
- this.load();
- </method>
-
- <handler name="onload">
- Debug.write('temperature service loaded!');
- Debug.write('---');
-
- // don't allow others to call RPC object until proxy is loaded.
- canvas.convert.setVisible(true);
- </handler>
-
- </soap>
-
- <button name="convert" text="convert" x="10" y="10"
visible="false">
-
- <attribute name="myDel"
- value="$once{new LzDelegate(this, 'myhandler')}" />
-
- <handler name="onclick">
- var f = 100;
- canvas.temperature.proxy.FtoC([ f ], this.myDel)
- Debug.write('Invoking FtoC...');
- </handler>
-
- <method name="myhandler" args="data">
- Debug.write('got data:', data);
- </method>
-
- </button>
-
- </canvas>
+ <canvas debug="true" height="280">
+
+ <debug x="10" y="40" width="470" height="230" />
+
+ <soap name="temperature" autoload="false"
+
wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
+ <method name="init">
+ super.init();
+ Debug.write('soap service loading...');
+ this.load();
+ </method>
+ <handler name="onload">
+ Debug.write('temperature service loaded!');
+ Debug.write('---');
+
+ // don't allow others to call RPC object until proxy is loaded.
+ canvas.convert.setAttribute('visible', true);
+ </handler>
+ </soap>
+ <button name="convert" text="convert" x="10" y="10"
visible="false">
+ <attribute name="myDel" value="$once{new LzDelegate(this,
'myhandler')}" />
+ <handler name="onclick">
+ var f = 100;
+ canvas.temperature.proxy.FtoC([ f ], this.myDel)
+ Debug.write('Invoking FtoC...');
+ </handler>
+ <method name="myhandler" args="data">
+ Debug.write('got data:', data);
+ </method>
+
+ </button>
+
+ </canvas>
</example>
+ <p>Alternatively, you can use remotecall for a more
declarative approach to invoking functions.
+ See the remotecall reference or the RPC chapter of the
Developer's Guide for more information.</p>
+ <example title="Invoking remote function using remotecall">
+ <canvas debug="true" height="280">
+
+ <debug x="10" y="40" width="470" height="230" />
+
+ <soap name="temperature" autoload="false"
+
wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
+
+ <method name="init">
+ super.init();
+ Debug.write('soap service loading...');
+ this.load();
+ </method>
+
+ <handler name="onload">
+ Debug.write('temperature service loaded!');
+ Debug.write('---');
+
+ // don't allow others to call RPC object until proxy is loaded.
+ canvas.convert.setAttribute('visible', true);
+ </handler>
+
+ <remotecall funcname="FtoC">
+ <param value="100" />
+
+ <handler name="ondata" args="value">
+ Debug.write('got data:', value);
+ </handler>
+ <handler name="onerror" args="errmsg">
+ Debug.write('error:', errmsg);
+ </handler>
+
+ </remotecall>
+
+ </soap>
+
+ <button name="convert" text="convert" x="10" y="10" visible="false">
+ <handler name="onclick">
+ canvas.temperature.FtoC.invoke();
+ Debug.write('Invoking FtoC...');
+ </handler>
+ </button>
+
+ </canvas>
+ </example>
+ <p><b>See Also:</b></p>
+ <ul>
+ <li>
+ <a href="../reference/javarpc.html"><code
class="classname">javarpc</code></a>
+ </li>
+ <li>
+ <a href="../reference/soap.html"><code
class="classname">soap</code></a>
+ </li>
+ <li>
+ <a href="../reference/xmlrpc.html"><code
class="classname">xmlrpc</code></a>
+ </li>
+ <li>
+ <a href="../reference/remotecall.html"><code
class="classname">remotecall</code></a>
+ </li>
+ <li>
+ <a href="../guide/rpc.html" target="laszlo-dguide"
shape="rect">Developer's Guide: RPC chapter</a>
+ </li>
+ <li>
+ <a href="../guide/rpc-javarpc.html"
target="laszlo-dguide" shape="rect">Developer's Guide: JavaRPC chapter</a>
+ </li>
+ <li>
+ <a href="../guide/rpc-soap.html"
target="laszlo-dguide" shape="rect">Developer's Guide: SOAP chapter</a>
+ </li>
+ <li>
+ <a href="../guide/rpc-xmlrpc.html"
target="laszlo-dguide" shape="rect">Developer's Guide: XML-RPC chapter</a>
+ </li>
+ </ul>
+
</text>
</doc>
</class>
-
- <!--- A class to invoke rpc methods more declaratively. -->
<class name="remotecall" extends="node">
<!--- Name of remotecall. Default is value of funcname attribute. -->
<attribute name="name" value="$once{null}" />
@@ -276,7 +341,7 @@
LzDelegate passed in contains a property called 'dataobject', the
return value will be mapped to it. The dataobject property can be
a dataset or a LzDataElement object.
- @return Number the unique sequence request number associated with
+ @return Number: the unique sequence request number associated
with
this call, or -1 if there was a problem invoking this method. -->
<method name="invoke" args="params, delegate">
<![CDATA[
@@ -390,7 +455,238 @@
}
]]>
</method>
+ <doc>
+ <tag name="shortdesc"><text>A class to use rpc methods
declaratively</text></tag><text>
+ <p>The <remotecall> element allows for a more declarative
style approach to using RPC functions. Calling
+ function stubs will generally result in your code looking very
scripty.</p>
+ <p>Remotecall requires the funcname attribute to be set. Funcname
refers to the remote function name. By default,
+ the name of the remotecall is the same as funcname unless
explicitly set to something else. Multiple remotecalls
+ can refer to the same funcname, but remotecall names must be
unique within the same element context.</p>
+ <p><param> elements declared in the remotecall body are used
when invoking the remote function. The declaration order of
+ <param>s should match what the remote function expects.</p>
+ <example title="Using RPC methods">
+ <canvas debug="true" height="280">
+
+ <debug x="10" y="40" width="470" height="230" />
+
+ <soap name="temperature" autoload="false"
+
wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
+
+ <method name="init">
+ super.init();
+ Debug.write('soap service loading...');
+ this.load();
+ </method>
+
+ <handler name="onload">
+ Debug.write('temperature service loaded!');
+ Debug.write('---');
+
+ // don't allow others to call RPC object until proxy is loaded.
+ canvas.convert.setAttribute('visible', true);
+ </handler>
+
+ <handler name="ondata" args="value">
+ Debug.write('soap object parent ondata:', value);
+ </handler>
+
+ <remotecall <em>name="ftoc1" funcname="FtoC"</em>>
+ <param value="100" />
+ </remotecall>
+
+ <remotecall <em>name="ftoc2" funcname="FtoC"</em>>
+ <param value="200" />
+ <handler name="ondata" args="value">
+ Debug.write('ftoc ondata:', value);
+ </handler>
+ </remotecall>
+
+ </soap>
+
+ <view name="convert" x="10" y="10" visible="false"
+ layout="axis: x; spacing: 5">
+ <button text="convert 100F to C">
+ <handler name="onclick">
+ canvas.temperature.ftoc1.invoke()
+ Debug.write('Invoking FtoC 1...');
+ </handler>
+ </button>
+ <button text="convert 200F to C">
+ <handler name="onclick">
+ canvas.temperature.ftoc2.invoke()
+ Debug.write('Invoking FtoC 2...');
+ </handler>
+ </button>
+ </view>
+
+ </canvas>
+ </example>
+ <p>Any events not handled by remotecall can be handled by
a remotecall's parent. A remotecall element can be
+ declared anywhere in the view hierarchy. However, if
it's not within an RPC object
+ (like <soap>, <javarpc, <xmlrpc>), the
remotecontext attribute must be set. The remotecontext tells the
+ remotemethod which RPC object t>o refer to when
invoking the remote method.</p>
+ <example>
+ <canvas debug="true" height="280">
+
+ <debug x="10" y="40" width="470" height="230" />
+
+ <soap name="temperature" autoload="false"
+
wsdl="http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter">
+
+ <method name="init">
+ super.init();
+ Debug.write('soap service loading...');
+ this.load();
+ </method>
+
+ <handler name="onload">
+ Debug.write('temperature service loaded!');
+ Debug.write('---');
+
+ // don't allow others to call RPC object until proxy is loaded.
+ canvas.convert.setAttribute('visible', true);
+ </handler>
+
+ <handler name="ondata" args="value">
+ Debug.write('soap object ondata:', value);
+ </handler>
+
+ <handler name="onerror" args="errmsg">
+ Debug.write('error:', errmsg);
+ </handler>
+
+ </soap>
+
+ <view name="convert" x="10" y="10" visible="false"
+ layout="axis: x; spacing: 5">
+
+ <button text="convert 100F to C">
+
+ <handler name="onclick">
+ this.FtoC.invoke()
+ Debug.write('Converting 100F to Celsius...');
+ </handler>
+
+ <remotecall funcname="FtoC"
+ remotecontext="$once{canvas.temperature}">
+ <param value="100" />
+ </remotecall>
+
+ </button>
+
+ <button text="convert 200F to C">
+
+ <handler name="onclick">
+ this.FtoC.invoke()
+ Debug.write('Converting 200F to Celsius...');
+ </handler>
+
+ <remotecall funcname="FtoC"
+ remotecontext="$once{canvas.temperature}">
+ <param value="200" />
+ <handler name="ondata" args="value">
+ Debug.write('200F in Celsius is', value);
+ </handler>
+ </remotecall>
+ </button>
+ </view>
+
+ </canvas>
+</example>
+<p>The order in which events (ondata, onerror) are handled are as follow:</p>
+<ol>
+
+ <li>Use event handler defined in remotecall.</li>
+
+ <li>Else use event handler defined in parent.</li>
+
+ <li>Else if remotecall is defined outside of RPC object (i.e. remotecontext
+ attribute is set) use event handler defined in RPC object (i.e.
remotecontext
+ value).</li>
+
+ <li>Otherwise event is not handled.</li>
+
+</ol>
+<p>To databind to a successful return value, you can set the dataobject
+ attribute to a dataset. For more information on databinding with RPC, see
the
+ <a href="../guide/rpc.html" target="laszlo-dguide" shape="rect">RPC
chapter</a></p>
+<example>
+ <canvas debug="true" height="300" width="680">
+
+ <debug x="225" width="450" height="280" />
+
+ <dataset name="googleDset" />
+
+ <soap name="google"
wsdl="http://api.google.com/GoogleSearch.wsdl">
+ <handler name="onload">
+ Debug.write('google soap service stub loaded');
+ </handler>
+
+ <handler name="onerror" args="error">
+ Debug.write('error:', error);
+ </handler>
+
+ <remotecall name="search" funcname="doGoogleSearch"
+ dataobject="googleDset">
+
+ <param value="'2TKUw4ZQFHJ84ByemZK0EXV0Lj+7xGOx'" />
+ <param value="'sweet'" />
+ <param value="1" />
+ <param value="10" />
+ <param value="true" />
+ <param value="''" />
+ <param value="true" />
+ <param value="''" />
+ <param value="''" />
+ <param value="''" />
+
+ <handler name="ondata" args="value">
+ Debug.write('got result');
+ Debug.inspect(value);
+ </handler>
+
+ </remotecall>
+ </soap>
+
+ <view layout="spacing: 5" >
+ <button text="search" onclick="google.search.invoke()" />
+ <view bgcolor="yellow" layout="axis: y" >
+ <view>
+ <datapath xpath="googleDset:/resultElements/item"
pooling="true" />
+ <text datapath="URL/text()" resize="true"/>
+ </view>
+ </view>
+ </view>
+ </canvas>
+ </example>
+
+
+ <p><b>See Also:</b></p>
+
+ <ul>
+ <li>
+ <a href="../reference/param.html"><code
class="classname">param</code></a>
+ </li>
+ <li>
+ <a href="../reference/rpc.html"><code
class="classname">rpc</code></a>
+ </li>
+ <li>
+ <a href="../reference/javarpc.html"><code
class="classname">javarpc</code></a>
+ </li>
+ <li>
+ <a href="../reference/soap.html"><code
class="classname">soap</code></a>
+ </li>
+ <li>
+ <a href="../reference/xmlrpc.html"><code
class="classname">xmlrpc</code></a>
+ </li>
+ <li>
+ <a href="../guide/rpc.html" target="laszlo-dguide"
shape="rect">Developer's Guide: RPC chapter</a>
+ </li>
+ </ul>
+ </text>
+ </doc>
+
</class>
@@ -401,6 +697,44 @@
value attribute and getValue method are declared, param will use
getValue(). -->
<attribute name="value" value="null" type="expression" />
+ <doc>
+ <tag name="shortdesc"><text>param tag for remotecall</text></tag>
+ <text>
+ <p>Tag to declaratively set parameter values for
<remotecall>. If a
+ getValue method is declared in the body of remotecall, use
its return as
+ value for paramter. If both getValue method and value
attribute are set in
+ param, getValue wins.</p>
+ <programlisting title="Usage example">
+ <remotecall name="func1" funcname="someFunc">
+ <param value="'some string value'" />
+ </remotecall>
+
+ <remotecall name="func2" funcname="someFunc">
+ <param>
+ <method name="getValue">
+ return 'some string value';
+ </method>
+ </param>
+ </remotecall>
+
+ <remotecall name="func2" funcname="someFunc">
+ <!-- param will use getValue's return value. -->
+ <param value="'a value'">
+ <method name="getValue">
+ return 'some string value';
+ </method>
+ </param>
+ </remotecall>
+ </programlisting>
+ <p> <b>See Also:</b></p>
+ <ul>
+ <li>
+ <a href="../reference/remotecall.html"><code
class="classname">remotecall</code></a>
+ </li>
+ </ul>
+
+ </text>
+ </doc>
</class>
</library>
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins