<?xml version="1.0" encoding="UTF-8"?>
<otrunk id="b6d7d50b-fe2f-4265-80b6-c9769184a258">
  <imports>
    <import class="org.concord.otrunk.OTSystem" />
    <import class="org.concord.otrunk.view.OTViewBundle" />
    <import class="org.concord.otrunk.view.OTViewEntry" />
    <import class="org.concord.otrunk.view.document.OTCompoundDoc" />
    <import class="org.concord.otrunk.ui.OTText" />
    <import class="org.concord.otrunk.script.ui.OTXHTMLScript" />
    <import class="org.concord.otrunk.script.ui.OTScriptVariable" />
    <import class="org.concord.otrunk.script.js.OTJavascript" />
    <import class="org.concord.otrunk.script.OTScriptEngineBundle" />
    <import class="org.concord.otrunk.script.OTScriptEngineEntry" />
  </imports>
  <objects>
    <OTSystem>
      <bundles>
        <OTViewBundle>
          <views>
            <OTViewEntry objectClass="org.concord.otrunk.ui.OTText" viewClass="org.concord.otrunk.ui.swing.OTTextEditView" />
            <OTViewEntry objectClass="org.concord.otrunk.script.ui.OTXHTMLScript" viewClass="org.concord.otrunk.script.ui.OTXHTMLScriptView" />
            <OTViewEntry objectClass="org.concord.otrunk.view.document.OTDocument" viewClass="org.concord.otrunk.view.document.OTDocumentView" />
            <OTViewEntry local_id="script_edit_view" objectClass="org.concord.otrunk.script.OTScript" viewClass="org.concord.otrunk.script.ui.OTScriptEditView" />
          </views>
        </OTViewBundle>
        <OTScriptEngineBundle>
          <engines>
            <OTScriptEngineEntry objectClass="org.concord.otrunk.script.js.OTJavascript" engineClass="org.concord.otrunk.script.js.OTJavascriptEngine" />
          </engines>
        </OTScriptEngineBundle>
      </bundles>
      <root>
        <OTCompoundDoc name="root">
          <bodyText>
            <h3>An Example of using javascript to generate xhtml</h3>
            <ul>
            <li>Click the document to the left to see the result of running the script.</li>
            <li>Click the script to the left to edit the script.</li>
            </ul>
          </bodyText>
          <children>
            <OTCompoundDoc name="document">
              <bodyText>
                The text below the textbox is generated by a
      					script. The script is pulling data from the
      					text box. If you change the text in the text
      					box and then click on another item on the left and then click on the document again
      					you will see the change.
                <br />
                <object refid="${text_object}" />
                <br />
                <object refid="${script_object}" />
                <br />
              </bodyText>
            </OTCompoundDoc>
            <OTJavascript name = "script" local_id="script">
              <script>function getText() { 
// This function is called when the page is loaded. And its return value
// is embedded in the page. If you are looking at this script in the otml file you'll 
// notice how the xml chars are escaped. 
var text; 
text = "This demonstrates how to create text with javascript&lt;br/&gt;"; 
text += "It can be appended like this: " + myTextVariable.getText() + "&lt;br/&gt;";
return text; 
}</script>
            </OTJavascript>
          </children>
        </OTCompoundDoc>
      </root>
      <library>
        <OTText local_id="text_object" text="Hello" />
        <OTXHTMLScript local_id="script_object">
          <script>
            <object refid="${script}" />
          </script>
          <variables>
            <OTScriptVariable name="myTextVariable">
              <reference>
                <object refid="${text_object}" />
              </reference>
            </OTScriptVariable>
          </variables>
        </OTXHTMLScript>
      </library>
    </OTSystem>
  </objects>
</otrunk>

