example of getting dojo and PermaCrud to work with xul
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Jul 2009 03:55:35 +0000 (03:55 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Jul 2009 03:55:35 +0000 (03:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13679 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/external/dojo_template.js [new file with mode: 0644]
Open-ILS/xul/staff_client/external/dojo_template.xul [new file with mode: 0644]

diff --git a/Open-ILS/xul/staff_client/external/dojo_template.js b/Open-ILS/xul/staff_client/external/dojo_template.js
new file mode 100644 (file)
index 0000000..a3bac8f
--- /dev/null
@@ -0,0 +1,44 @@
+var error;
+
+function my_init() {
+    try {
+        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+        if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+        JSAN.errorLevel = "die"; // none, warn, or die
+        JSAN.addRepository('/xul/server/');
+        JSAN.use('util.error'); error = new util.error();
+        error.sdump('D_TRACE','my_init() for main_test.xul');
+
+        /* these were not working as <script> tags.  Maybe someone else can try? */
+        var url="/js/dojo/dojo/dojo.js"; var js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/DojoSRF.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/fieldmapper/Fieldmapper.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/fieldmapper/hash.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/fieldmapper/OrgUtils.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/openils/Event.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/openils/Util.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/openils/User.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+        url="/js/dojo/openils/PermaCrud.js"; js = JSAN._loadJSFromUrl( url ); eval(js);
+
+        var types = new openils.PermaCrud(
+            {
+                authtoken :ses()
+            }
+        ).retrieveAll('coust');
+
+        dojo.forEach(types,
+            function(type) {
+                alert( js2JSON(type) );
+            }
+        );
+
+        if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+            try { window.xulG.set_tab_name('Test'); } catch(E) { alert(E); }
+        }
+
+    } catch(E) {
+        try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
+    }
+}
+
+
diff --git a/Open-ILS/xul/staff_client/external/dojo_template.xul b/Open-ILS/xul/staff_client/external/dojo_template.xul
new file mode 100644 (file)
index 0000000..32d1235
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Example Template for remote xul -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+       <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="main_test_win" 
+       onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+       <script type="text/javascript">
+               var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; 
+       </script>
+       <scripts id="openils_util_scripts"/>
+
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script type="text/javascript" src="/opac/common/js/opensrf.js"/>
+       <script type="text/javascript" src="/opac/common/js/opensrf_xhr.js"/>
+       <script type="text/javascript" src="dojo_template.js"/>
+
+    <label value="retrieving coust's with dojo and PermaCrud..."/>
+
+</window>
+