cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@apache.org>
Subject Calling namespaced JavaScript from the SItemap
Date Sun, 19 Nov 2006 14:31:00 GMT
Hi Guys

I am experimenting with namespaced Javascript for FlowScript functions.

I am trying to call this FlowScript from this sitemap and I am  
getting 'not found' errors :

URL: system/upload/status

Sitemap :
<map:match pattern="system/upload/*">
   <map:call function="System.Upload.{1}">
     <map:parameter name="catalogue" value="messages"/>
     <map:parameter name="location" value="i18n"/>
   </map:call>
</map:match>


FlowScript :
// setup the extensible namespace
var System = System || {};
System.Upload = System.Upload || {};

// test the namespace's existence for debugging
print("System : " + (System != undefined));               // shows  
'true'
print("System.Upload : " + (System.Upload != undefined)); // shows  
'true'

// the target function
System.Upload.status = function() {
	// snip the function body
};

// test to see if the function exists
print("System.Upload.status : " + typeof System.Upload.status); //  
shows "function"


Here is a snippet from the stacktrace :

org.apache.cocoon.ResourceNotFoundException: Function  
"javascript:System.Upload.status()" not found
	at <map:call> - file:/Users/Shared/Development/Checkouts/FiveOne/ 
Uploader/application/webapp/sitemap.xmap:117:43
	at <map:mount> - file:/Users/Shared/Development/Checkouts/Apache/ 
Cocoon/Cocoon_2_1_X/build/webapp/sitemap.xmap:1397:57
	at  
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpret 
er.callFunction(FOM_JavaScriptInterpreter.java:749)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invo 
ke(CallFunctionNode.java:139)

It looks like Rhino is unable to detect the function at this line :

FOM_JavaScriptInterpreter: line 747 :

	Object fun = ScriptableObject.getProperty(thrScope, funName);

Where ScriptableObject is org.mozilla.javascript.ScriptableObject

This style of coding usually works fine, just not when called from  
the Sitemap though .....

Does anyone have any ideas what I am doing wrong, or is this a known  
issue ?

Many thanks

regards Jeremy



Mime
View raw message