cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lundquist ...@wrinkledog.com>
Subject Re: call a function not in global object in <map:call >
Date Tue, 14 Nov 2006 08:14:40 GMT

On Nov 13, 2006, at 10:14 PM, Rice Yeh wrote:

> Thank you. Will this patch go into the trunk eventually?

It's up to the committers.  I'm sure they will take a look at it and  
decide if they think it's a good way.

But if you want to try a trunk version, here it is.  I couldn't get  
trunk to build, so you might have to fix this if it doesn't compile :-/

cheers,
—ml—

==================================================================
---  
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/ 
apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java     (revision 474689)
+++  
blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/ 
apache/cocoon/components/flow/javascript/fom/ 
FOM_JavaScriptInterpreter.java     (working copy)
@@ -593,11 +593,19 @@
                      }
                      cocoon.setParameters(parameters);

-                    Object fun =  
ScriptableObject.getProperty(thrScope, funName);
-                    if (fun == Scriptable.NOT_FOUND) {
-                        throw new ResourceNotFoundException("Function  
\"javascript:" + funName + "()\" not found");
+                    // Resolve function name
+                    //
+                    Object fun;
+                    try {
+                        fun = context.compileString (funName, null, 1,  
null)
+                                         .exec (context, thrScope);
+                    } catch (EcmaError ee) {
+                       throw new ResourceNotFoundException (
+                            "Function \"javascript:" + funName + "()\"  
not found"
+                        );
                      }


Mime
View raw message