cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@apache.org>
Subject Re: call a function not in global object in <map:call >
Date Sun, 19 Nov 2006 18:38:36 GMT
Hi Mark

Many thanks for getting back to me so quickly.

It compiled fine, and it seems to work with both namespaced and non- 
namespaced JavaScript.

regards Jeremy


On 13 Nov 2006, at 03:14, Mark Lundquist wrote:

>
> On Nov 12, 2006, at 1:31 AM, I wrote:
>
>> [...snip] Here's a patch you can try.  [...snip]
>
> Do'h. my bad!  I didn't realize when I sent you that diff that I  
> was in the middle of changing the code from its first working  
> form.   Sorry for going off half cocked; here's a version that  
> actually works... :-/
>
> ===================================================================
> --- 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,17 @@
>                      }
>                      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.compileReader (
> +                                    thrScope, new StringReader  
> (funName), null, 1, null
> +                                ).exec (context, thrScope);
> +                    } catch (EcmaError ee) {
> +                       throw new ResourceNotFoundException (
> +                            "Function \"javascript:" + funName +  
> "()\" not found"
> +                        );
>                      }
>
> Cheers,
> —ml—
>


Mime
View raw message