PHP Classes

File: docs/tutorial.html

Recommend this page to a friend!
  Classes of sunish   RSPA   docs/tutorial.html   Download  
File: docs/tutorial.html
Role: Documentation
Content type: text/plain
Description: tutorial.html
Class: RSPA
Process browser events on the server using AJAX
Author: By
Last change:
Date: 18 years ago
Size: 9,479 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>RSPA Tutorial</title> </head> <body> <h1 style="font-weight: normal;"><big><big>Tutorial</big></big>&nbsp;&nbsp; <br> </h1> <table style="width: 100%; text-align: left;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="vertical-align: top;"><br> </td> <td style="vertical-align: top; text-align: right;"><a href="index.html">Home</a>&nbsp; -&nbsp;&nbsp; <a href="examples.html">Online Examples</a><br> </td> </tr> <tr> <td style="vertical-align: top;"><br> </td> <td style="vertical-align: top;"><br> </td> </tr> </tbody> </table> <h1 style="font-weight: normal;"></h1> <h3>&nbsp;&nbsp; <big style="font-weight: bold;">Some Prerequisits</big></h3> <br> <ol> <big> </big><li><big>PHP 4 or later (on server).</big></li> <big> </big><li><big>Javascript enabled browser (I tested it on Firefox1.0 + and IE 5.5+).</big></li> <big></big> </ol> <big>&nbsp;&nbsp; I may add other prerequisits later.</big><br> <br> <h3><big>Simple Usage:</big></h3> <big>&nbsp; &nbsp; <br> 1.&nbsp; In HTML file include the rspa.js <br> <br> <big><span style="color: rgb(204, 51, 204);">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <small>&lt;script </small></span><small><span style="color: rgb(51, 204, 0);">language</span>=<span style="color: rgb(51, 51, 255);">"JavaScript"</span> <span style="color: rgb(51, 204, 0);">type</span>=<span style="color: rgb(51, 51, 255);">"text/javascript"</span><span style="color: rgb(51, 204, 0);">src</span>=<span style="color: rgb(51, 51, 255);">"rspa/rspa.js"</span><span style="color: rgb(204, 51, 204);">&gt;&lt;/script&gt;</span></small> </big><br> &nbsp;&nbsp; <br> 2. Provide ID and name for controls like:<br> <br> <span style="color: rgb(204, 51, 204);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <small>&nbsp;&nbsp; &lt;input</small></span><small> <span style="color: rgb(51, 204, 0);">name</span>=<span style="color: rgb(51, 51, 255);">"<big style="font-weight: bold;">text1</big>"</span> <span style="color: rgb(51, 204, 0);">id</span>=<span style="color: rgb(51, 51, 255);">"<big style="font-weight: bold;">text1</big>"</span> <span style="color: rgb(51, 204, 0);">value</span>=<span style="color: rgb(51, 51, 255);">"20"</span><span style="color: rgb(204, 51, 204);">&gt;<br> </span><span style="color: rgb(204, 51, 204);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input</span> <span style="color: rgb(51, 204, 0);">name</span>=<span style="color: rgb(51, 51, 255);">"<big><span style="font-weight: bold;">text2</span></big>"</span> <span style="color: rgb(51, 204, 0);">id</span>=<span style="color: rgb(51, 51, 255);">"<big style="font-weight: bold;">text2</big>"</span> <span style="color: rgb(51, 204, 0);">value</span>=<span style="color: rgb(51, 51, 255);">"30"</span><span style="color: rgb(204, 51, 204);">&gt;<br> </span><span style="color: rgb(204, 51, 204);"></span><span style="color: rgb(204, 51, 204);"></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Result:&nbsp; <span style="color: rgb(204, 51, 204);">&lt;input</span> <span style="color: rgb(51, 204, 0);">name</span>=<span style="color: rgb(51, 51, 255);">"text3"</span> <span style="color: rgb(51, 204, 0);">id</span>=<span style="color: rgb(51, 51, 255);">"<big style="font-weight: bold;">text3</big>"</span> <span style="color: rgb(51, 204, 0);"></span><span style="color: rgb(204, 51, 204);">&gt;</span><br> &nbsp;</small><br> 3. Call server functions from javascript events<br> <br> <span style="color: rgb(204, 51, 204);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<small> &lt;input</small></span><small> <span style="color: rgb(51, 204, 0);">type</span>=<span style="color: rgb(51, 51, 255);">"button"</span> <span style="color: rgb(51, 204, 0);">id</span>=<span style="color: rgb(51, 51, 255);">"button1"</span> <span style="color: rgb(51, 204, 0);">value</span>=<span style="color: rgb(51, 51, 255);">"Calculate"</span><span style="color: rgb(204, 51, 204);">&nbsp; </span></small><span style="color: rgb(51, 204, 0);">onclick</span>=<span style="color: rgb(51, 51, 255);">"&nbsp;new RSPA.Execute(<span style="font-weight: bold;">'MyClass.multiply()'</span>) "</span><small><span style="color: rgb(204, 51, 204);"></span><span style="color: rgb(204, 51, 204);"> &gt;</span></small><br> <br> <br> 4. Create the PHP class MyClass&nbsp; in MyClass.class.php<br> <br> <br> <span style="color: rgb(204, 102, 204);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;?php</span><br> <br> <span style="color: rgb(153, 51, 153);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; require_once</span>(<span style="color: rgb(51, 51, 255);">"rspa/components/Form.class.php"</span>);<br> <br> <span style="color: rgb(153, 51, 153);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class</span> <span style="font-weight: bold;">MyClass</span><small style="font-weight: bold;">&nbsp;</small> <span style="color: rgb(153, 51, 153);">extends</span> <span style="font-weight: bold;">Form</span><small style="font-weight: bold;">{</small><br> <br> &nbsp;&nbsp; <br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: rgb(153, 51, 153);">public</span> <span style="color: rgb(153, 51, 153);">function</span> <span style="font-weight: bold;">multiply()</span><small style="font-weight: bold;"> </small>{<br> &nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: rgb(51, 153, 153);">$val</span> = <span style="color: rgb(51, 153, 153); font-weight: bold;">$this</span><span style="font-weight: bold;">-&gt;controls[</span><span style="color: rgb(51, 51, 255); font-weight: bold;">"text1"</span><span style="font-weight: bold;">]-&gt;getValue() * </span><span style="color: rgb(51, 153, 153); font-weight: bold;">$this</span><span style="font-weight: bold;">-&gt;controls[</span><span style="color: rgb(51, 51, 255); font-weight: bold;">"text2"</span><span style="font-weight: bold;">]-&gt;getValue();</span><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(51, 153, 153); font-weight: bold;">$this</span><span style="font-weight: bold;">-&gt;controls["text3"]-&gt;setValue(</span><span style="color: rgb(51, 153, 153); font-weight: bold;">$val</span><span style="font-weight: bold;">);</span><br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br> &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> <br> <span style="color: rgb(204, 102, 204);">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ?&gt;<br> <br> </span> &nbsp; 5. Change the configuration value in rspaconf.inc.php<br> <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $RSPA['class_folder'] &nbsp;has to set to the folder containg your class files.<br> <br> <br> <br> Syntax of calling Execute:<br> <br> new RSPA.Execute('Class.function', {option :value,...});<br> <br> Applicable oprtions :<br> &nbsp;&nbsp;&nbsp; <small>&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; &nbsp;</small></big><small><span style="font-weight: bold;">debug: </span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Whether to show debug window(true/false). Default is false<br> &nbsp;&nbsp;&nbsp; &nbsp; <span style="font-weight: bold;">loadStatus: </span>&nbsp; //Status message to be displayed while waiting for execute. Default 'Loading...'<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">statusPane:</span> &nbsp;//Where to show status message . Default is '__RSPA__loadStatus',<br> </small><big><small><small>&nbsp;&nbsp;&nbsp; &nbsp;<span style="font-weight: bold;">&nbsp;widget:&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; //ID of the parent component whose child values to be passed to server for execution. Default is&nbsp; document. By default it will pass all components you can restrict it by using a div to nest components.<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">parameters:</span>&nbsp; //An array of parameters to be passed to server function. Default is empty array (new Array())<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">controller:</span> &nbsp; &nbsp; //Relative location of RSPA controller on server. Default:&nbsp; "rspa/framework/Controller.php"</small>&nbsp;&nbsp;&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small><span style="font-weight: bold;">oncomplete:</span> &nbsp;// Client side function to execute after getting result from server. Default is null</small></small><br> <br> <br> </big> <h4 style="font-weight: bold;"><big><big>Class Diagram of components</big></big></h4> <big><img style="width: 896px; height: 750px;" alt="Classdiagram" src="images/class_diagram.png"><br> <br> &nbsp;&nbsp;&nbsp; </big><br> </body> </html>