On Nov 11, 2006, at 9:16 AM, Rice Yeh wrote:

Hi,
  It seems for now the function attribute in <map:call> must be a function in the global object. I think it might be better if this function could be within a scope object because our project groups all javascript objects like java packages (or just like what dojo does).

Agreed.

Here's a patch you can try. I couldn't figure out how to do it the "real" way, so... this way feels kind of sleazy, but it works :-)

Index: src/java/org/apache/cocoon/components/flow/javascript/fom/ FOM_JavaScriptInterpreter.java
===================================================================
--- src/java/org/apache/cocoon/components/flow/javascript/fom/ FOM_JavaScriptInterpreter.java (revision 472699) +++ src/java/org/apache/cocoon/components/flow/javascript/fom/ FOM_JavaScriptInterpreter.java (working copy)
@@ -69,6 +69,7 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.PushbackInputStream;
+import java.io.StringReader;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -744,9 +745,15 @@
                     }
                     cocoon.setParameters(parameters);

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

If some other Cocoon developers think this is not too lame :-), then I will make it official and fire up a JIRA issue.

There are more javascript codes than java codes in our project, so goruping them in different naming spaces is needed. Cocoon itself is a good environment for easily javascript coding at the server side with its flowscript and continuation.

Yes :-)

However, it seems not that care about naming space at javascript code itself. Maybe some ideas from dojo can be borrowed here. Like dojo has dojo naming space, cocoon has cocoon naming space, and within cocoon, there are cocoon.flow, cocoon.flow.continuation,...

I agree, Cocoon's own Javascript style is kind of flat that way.

—ml—

Reply via email to