Location: A review of cardiac cellular electrophysiology models @ a80b964384c0 / dojo-presentation / js / dojo / dojox / dtl / tests / demo_Templated_Jaxer.html

Author:
David Nickerson <nickerso@users.sourceforge.net>
Date:
2010-05-04 12:37:19+12:00
Desc:
adding initial version of SED-ML L1V1 file reproducing what is in graphs/BR-INa-variants.xml
Permanent Source URI:
https://models.cellml.org/workspace/a1/rawfile/a80b964384c0c7683d7c5d07b73a5af7a973d46c/dojo-presentation/js/dojo/dojox/dtl/tests/demo_Templated_Jaxer.html

Using Dojo's Django Template language on Jaxer

Aptana's Jaxer is server side JavaScript (SSJS) server. With some modifications to a web page, Dojo can be run on the server. With Dojo running on the server, you can utilize the Dojo's Django Template library rendering engine to do templating within Jaxer. The latest build of Dojo includes some patches to properly work with Jaxer, so you need a build of Dojo later than 2/18/08 to work with Jaxer. Next, the following modifications to your page are needed to run Jaxer:

  • You must explicitly set the base url of the Dojo library. Jaxer does not provide the ability for Dojo to auto-detect the base url as it can in other environments. Therefore you must declare the base url with the djConfig global variable:
    <script runat="server">
    djConfig = {baseUrl:"/dojo/", // use the base path of dojo here
    			usePlainJson: true, parseOnLoad: true};
    </script>
    					
  • Next, you must add the runat attribute with a value of "server" to all of the script tags that you want executed on the server. Your script tags should look like:
    <script runat="server" type="text/javascript" src="../../../dojo/dojo.js"></script>
    					
  • Last, you must dojo.require("dojo.jaxer") with a script tag. This should immediately follow the declaration of dojo.js:
    <script runat="server" type="text/javascript" src="../../../dojo/dojo.js"></script>
    <script runat="server" type="text/javascript">dojo.require("dojo.jaxer");</script>
    					

Once this is done, Dojo should load in Jaxer, and you can utilize the library capabilities of Dojo. In particular, you can now use DTL renderer as you would on the browser. If you are running this in Jaxer, below should be a working demonstration of a template that is rendered on the server.

It is important to note that Jaxer is not capable of transferring the programmaticaly set event handlers for widgets, it can only send the static HTML to the browser. This means you can use DTL as a templating engine to create HTML on the server, but Dojo client side widgets are still necessary if you want to use interactive widgets on the browser.