Topic - problem getting javascript to work
Topic - problem getting javascript to work Topic - problem getting javascript to work
from forum Solutions Developer
 forum index   my profile   search 
 new topic  post reply 
moderators: pjr tab
problem getting javascript to work
Joined: 22-April-2007
Posts: 79
Location: Belgium
Posted: 3-September-2008 09:01
Greetings all,

This is my code ...
<html xmlns:xrl="http://1060.org/xrl">
  <head>
    <title>xHttpRequest Testing</title>
    <script language="javascript" src="[[xrl:xHttpRequest.js]]" xrl:resolve="src" type="text/javascript" />
    <script language="javascript" type="text/javascript">
      <!-- var XHRimpact = new xHttpRequest(); var XHRdependency = new xHttpRequest(); function Alter() { document.getElementById('impact').innerHTML = "<center><img src='http://10.111.8.161:1070/theplanone/images/ajax-loader.gif' width='32' height='32' alt='Loading ...'/></center>"; } --></script>
  </head>
  <body onload="Alter()">
    <div id="impact">Tryout</div>
  </body>
</html>


If I call this up (translating the [[xrl]] manually, as a file in a browser, it works. When I call it from NetKernel ... I get a "Object Expected" on the div-line.
Its really been wrestling to get javascript to work with NetKernel and this has me stumped.
Any pointers ?

Regards, Tom
right ... but how to use the Dojo toolkit
Joined: 22-April-2007
Posts: 79
Location: Belgium
Posted: 4-September-2008 07:52
Greetings all,

I got it to work, although I couldn't say for the world which one of my changes did the trick.
Also got the prototype-framework to work with NetKernel.

Lets up the ante ... did anyone get the Dojo toolkit to work with NetKernel
and if yes, would that person be so kind as to explain the how ;-) ? I don't
see how it could be done without defining each and every file in the XRLLinks.

Regards,
Tom

P.S. For those interested, my code (framework_demo.htm) now looks like this :
<html xmlns:xrl="http://1060.org/xrl">
  <head>
    <title>xHttpRequest Testing</title>
    <script language="Javascript" src="javascript/xHttpRequest.js" type="text/javascript" />
    <script language="javascript" type="text/javascript"> /* */ var XHRimpact = new xHttpRequest(); var XHRdependency = new xHttpRequest(); function sendImpact(myURL,myDATA,myElementId) { document.getElementById(myElementId).innerHTML = "&lt;center&gt;&lt;img src='images/ajax-loader.gif' width='32' height='32' alt='Loading ...'/&gt;&lt;/center&gt;"; if (XHRimpact.busy) { document.getElementById(myElementId).innerHTML = "&lt;center&gt;Busy with previous request ... Please Wait !!!&lt;/center&gt;"; } else { if (!XHRimpact.send('POST', myURL, myDATA, null, null, false, null, handleImpact)) { alert('Impact request did not get send'); } } } function sendDependency(myURL,myDATA,myElementId) { document.getElementById(myElementId).innerHTML = "&lt;center&gt;&lt;img src='images/ajax-loader.gif' width='32' height='32' alt='Loading ...'/&gt;&lt;/center&gt;"; if (XHRdependency.busy) { document.getElementById(myElementId).innerHTML = "&lt;center&gt;Busy with previous request ... Please Wait !!!&lt;/center&gt;"; } else { if (!XHRdependency.send('POST', myURL, myDATA, null, null, false, null, handleDependency)) { alert('Dependency request did not get send'); } } } function handleImpact(req, status, obj) { if (status == XHRimpact.OK) { document.getElementById('output_impact').innerHTML = req.responseText; } } function handleDependency(req, status, obj) { if (status == XHRdependency.OK) { document.getElementById('output_dependency').innerHTML = req.responseText; } } /* */ </script>
  </head>
  <body>
    <div id="output_impact">Tryout Impact</div>
    <div id="output_dependency">Tryout Dependency</div>
    <div>
      <input type="button" onclick="javascript:sendImpact('impact_tree','description=SVLIPC16','output_impact')" value="The Impact Button" />
      <input type="button" onclick="javascript:sendDependency('dependencies_tree','description=DS-JDBC-BANNER','output_dependency')" value="The Dependency Button" />
    </div>
  </body>
</html>


And the revelant entries in the XRLLinks.xml file look like this :
<links>
  <link>
    <name>framework-demo</name>
    <ext>/framework-demo</ext>
    <int>ffcpl:/resources/framework_demo.htm</int>
  </link>
  <link>
    <name>xHttpRequest.js</name>
    <ext>/javascript/xHttpRequest.js</ext>
    <int>ffcpl:/lib/xHttpRequest.js</int>
  </link>
</links>
encoding ... the problem was encoding
Joined: 22-April-2007
Posts: 79
Location: Belgium
Posted: 4-September-2008 14:29
Greetings,
In the mean time I figured out what went wrong originally.
I like these tags for embedding javascript :
[/* <![CDATA[ */
... code goes here ...
/* ]]> */


Why I like them ? Because you can then use URI's within your code. They get nicely translated.
But when using an active:xrl-html accessor, ... I run into an encoding phenomena. I haven't been able to figure out yet how I can keep the CDATA and NOT get the javascript "encoded".
With these tags everything works fine :
<!--
... code goes here ...
//-->

but then I have to fully qualify every reference I make to an URI.

If anyone knows how to make my forays into javascript somewhat easier ... I'm ready to listen ;-).

Regards,
Tom
encoding ... the problem was encoding
Joined: 22-April-2007
Posts: 79
Location: Belgium
Posted: 4-September-2008 14:30
Greetings,
In the mean time I figured out what went wrong originally.
I like these tags for embedding javascript :
[/* <![CDATA[ */
... code goes here ...
/* ]]> */


Why I like them ? Because you can then use URI's within your code. They get nicely translated.
But when using an active:xrl-html accessor, ... I run into an encoding phenomena. I haven't been able to figure out yet how I can keep the CDATA and NOT get the javascript "encoded".
With these tags everything works fine :
<!--
... code goes here ...
//-->

but then I have to fully qualify every reference I make to an URI.

If anyone knows how to make my forays into javascript somewhat easier ... I'm ready to listen ;-).

Regards,
Tom
Joined: 14-March-2005
Posts: 60
Location: Amsterdam, The Netherlands
Posted: 5-September-2008 10:38
Hi Tom,

I didn't tried Dojo yet. However, I've used various other frameworks I've used with NK, i.e. Backbase and Tibco GI. But I didn't use XRL. I always have these frameworks in separate modules, which I only use on my development machine. On the production sever the frameworks are served by Apache. So for example I've a Tibco module:

<?xml version="1.0" encoding="utf-8"?>
<module>
   <identity>
      <uri>urn:tibco</uri>
      <version>1.0.0</version>
   </identity>
   <info>
      <name>Tibco</name>
      <description>Tibco a RIA toolkit</description>
      <type>application</type>
   </info>
   <publisher>
      <name>Tibco</name>
      <uri>http://www.tibco.com/</uri>
   </publisher>
   <licence>
      <name>1060 Public License v1.0</name>
      <uri>http://www.1060research.com/license</uri>
   </licence>
   <export>
      <uri>
         <match>ffcpl:/Tibco/.*</match>
               <match>ffcpl:/entrypoints.xml</match>
      </uri>
      <class/>
   </export>
   <rewrite>
      <!-- some static files should get the proper MIME type -->
      <rule>
         <match>ffcpl:([^+]*\.css)(\+.*)?</match>
         <to>active:sloot.mime+mime@data:text/plain,text/css+file@ffcpl:$1</to>
      </rule>
      <rule>
         <match>ffcpl:([^+]*\.pdf)(\+.*)?</match>
         <to>active:sloot.mime+mime@data:text/plain,application/pdf+file@ffcpl:$1</to>
      </rule>
      <rule>
         <match>ffcpl:([^+]*\.ico)(\+.*)?</match>
         <to>active:sloot.mime+mime@data:text/plain,image/x-icon+file@ffcpl:$1</to>
      </rule>
      <rule>
         <match>ffcpl:([^+]*\.gif)(\+.*)?</match>
         <to>active:sloot.mime+mime@data:text/plain,image/gif+file@ffcpl:$1</to>
      </rule>
      <!-- access to the Tibco libraries -->
      <rule>
         <match>ffcpl:([^+]*)(\+.*)?</match>
         <to>ffcpl:$1</to>
      </rule>
   </rewrite>
   <mapping>
      <this>
         <!-- entrypoints -->
         <match>ffcpl:/entrypoints.xml</match>
         <!-- the Tibco libraries -->
         <match>ffcpl:/Tibco/.*</match>
         <!-- the temp dir -->
         <match>ffcpl:/temp/.*</match>
      </this>
      <import>
         <uri>urn:org:ten60:netkernel:ext:sys</uri>
      </import>
...
      <import>
         <uri>urn:sloot</uri>
      </import>
      <super/>
   </mapping>
</module>


The various versions of the framework endup in the Tibco subdirectory, e.g. Tibco/3_6_1/

And I've to register the module in the frontend fulcrum.

Now I can load them in my HTML pages as follows:

<html>
    <head>
        <title>TIBCO General Interface(TM) - Professional Edition</title>
   <link rel="shortcut icon" href="/isocat/interface/JSXAPPS/ISOcat/images/favicon.ico"/>
   <link rel="icon" href="/isocat/interface/JSXAPPS/ISOcat/images/favicon.gif" type="image/gif"/>
    </head>
   
    <body BGCOLOR="#9898a5" SCROLL="no"
          style="position:absolute;width:100%;height:100%;left:0px;top:0px;padding:0px;margin:0px;border:0px;overflow:hidden;">
       
        <div id="jsxmain" style="position:absolute;left:0px;top:0px;width:100%;height:100%;">
            <script type="text/javascript" src="/Tibco/3_6_1/JSX/js/JSX30.js"  <!-- LOOK HERE -->
                    jsxapppath="/isocat/interface/JSXAPPS/ISOcat/"
                    jsxlt="true"
            >
              <!-- keep the script tag alive -->
            </script>
        </div>
       
    </body>
</html>


And this works both on my development machine and the production server.

I don't know if this suits your needs, but maybe it helps a bit ...

Greetings,

Menzo

(see you in A'dam ;-)
 new topic  post reply  To find out about new replies to this post as they occur
please subscribe to one of these feeds:
AtomRSS moderate 
© 2003-2006, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.