PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/raxan/sdk/docs/embeddable-apps.html

http://raxan.googlecode.com/
HTML | 122 lines | 90 code | 25 blank | 7 comment | 0 complexity | 269bb1f30aa8af1b7e13eb2c78c80d82 MD5 | raw file
Possible License(s): GPL-2.0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  5. <title>Embeddable Apps - Raxan User Guide</title>
  6. <link href="../raxan/ui/css/master.css" rel="stylesheet" type="text/css" />
  7. <!--[if lt IE 8]> <link rel="stylesheet" href="../raxan/ui/css/master.ie.css" type="text/css"><![endif]-->
  8. <link href="../raxan/ui/css/default/theme.css" rel="stylesheet" type="text/css" />
  9. <link href="style.css" rel="stylesheet" type="text/css" />
  10. <link href="highlight/styles/default.css" rel="stylesheet" type="text/css" />
  11. <script type="text/javascript" src="highlight/highlight.js"></script>
  12. <script type="text/javascript">
  13. <!--
  14. hljs.initHighlightingOnLoad('javascript','html','php','css');
  15. //-->
  16. </script>
  17. <!--[if lt IE 7]>
  18. <style type="text/css"> form input.textbox { height: 26px; }</style>
  19. <![endif]-->
  20. </head>
  21. <body>
  22. <div class="container">
  23. <div id="header" class="rax-header-pal rax-metalic">
  24. <h2 class="ltm bottom c14">Raxan User Guide</h2>
  25. <ul>
  26. <li><a href="../../index.html">Home</a></li>
  27. <li><a href="index.html">Overview</a></li>
  28. <li><a href="features.html">Features</a></li>
  29. <li><a href="table-of-contents.html" title="Table of Content">Contents</a></li>
  30. <li><a href="../examples">Examples</a></li>
  31. </ul>
  32. <ul class="search">
  33. <li>
  34. <form class="tpm c9" name="form1" action="../tools/search.php" method="get">
  35. <input class="c6 textbox round left" placeholder="Search" type="text" name="q" value="" title="Search User Guide" />
  36. <input class="c2 button round left ltm" type="submit" value="Go" />
  37. </form>
  38. </li>
  39. </ul>
  40. </div>
  41. <hr class="space"/>
  42. <div class="master-content-wrapper">
  43. <div class="container prepend-top c48 master-content"><h2>Embeddable Applications</h2>
  44. <p>Raxan makes it possible to embed an Ajax application within another web page or application. With embeddable apps developers can use Raxan to
  45. extend or enhance their existing web pages without having to make any major changes or convert or port the entire web page to into PHP.</p>
  46. <h3>Other Benefits:</h3>
  47. <ol>
  48. <li>Embeddable apps can be used with static or dynamically generated web pages such as those generated by other languages such as Perl, JSP, ASP, ASP.Net, Ruby, Python, etc. </li>
  49. <li>They can also be used to manipulate and traverse the client-side DOM elements within a web page. This means that an application can be designed to add or remove elements as the user interacts with the web page.</li>
  50. </ol>
  51. <p>Creating an embedded application is the same as creating a typical Raxan for PHP Ajax web page. The one thing to bear in mind is that the application will only communicate with the client's browser via Ajax after first load. Full page post-backs are not recommended for embedded applications.</p>
  52. <h4><strong>Emebedded Hello World app</strong></h4>
  53. <p>This will add a button to the web page and will then display the 'Hello World' message when the button is clicked.</p>
  54. <pre><code class="php">&lt;?php
  55. require_once("raxan/pdi/autostart.php");
  56. class EmbeddedApp extends RaxanWebPage {
  57. protected function buttonClick(){
  58. // use the CLX to sent and alert action script to the client
  59. c()-&gt;alert('Hello World!!! - PHP Rules!');
  60. }
  61. }
  62. ?&gt;
  63. &lt;button id="button" xt-bind="#click,buttonClick"&gt;Click Me!&lt;/button&gt;
  64. </code></pre>
  65. <p>To load the above application inside your web page you only need to add a single script tag with the <strong>?embed[js]</strong> query string as shown below:</p>
  66. <pre><code class="javascript">&lt;script type="text/javascript" src="hello.php?embed[js]"&gt;&lt;/script&gt;
  67. </code></pre>
  68. <p>Using the above you can pass special instructions to the app to prevent it from loading external CSS or JavaScript files:</p>
  69. <pre><code class="javascript">&lt;script type="text/javascript" src="hello.php?embed[js]=noxcss,noxjs"&gt;&lt;/script&gt;
  70. </code></pre>
  71. <p>The noxcss option will prevent the loading of all external css files, while noxjs will prevent the loading of all external JavaScript files. These options will come in handy if you have already loaded a specific script of css file.</p>
  72. <h3>Sending Content To The Client</h3>
  73. <p>The appendToClient(), prependToClient, replaceClient() and updateClient() methods provide a convenient way for developers to transfer DOMs elements
  74. from the server to the client. Let's say you wanted to create a div on the server and then add the div inside an element called "sidebar", here's how
  75. it could be done in a single line:</p>
  76. <pre><code class="php">&lt;?php
  77. $div = $this['&lt;div id="box1" class="box" /&gt;'];
  78. $div-&gt;appendToClient('#sidebar');
  79. ?&gt;
  80. </code></pre>
  81. <p>You can also use the c() function to make jQuery calls from the server. For example: c('#sidebar')->html('This is a message from PHP');</p>
  82. <hr class="clear" />
  83. <p align="right">Up Next: <a href="degradable-pages.html" title="Creating Degradable Web Pages">Creating Degradable Web Pages</a> </p>
  84. </div>
  85. <div id="footer" class="container c48 rax-active-pal round rax-glossy">
  86. <ul class="clearfix">
  87. <li><a href="index.html">Overview</a></li>
  88. <li><a href="features.html">Features</a></li>
  89. <li><a href="new-features.html">What's new</a></li>
  90. <li><a href="table-of-contents.html" title="Table of Content">Contents</a></li>
  91. <li><a href="../examples">Examples</a></li>
  92. </ul>
  93. </div>
  94. </div>
  95. </div>
  96. </body>
  97. </html>