cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rice Yeh" <rice...@gmail.com>
Subject Re: call a function not in global object in <map:call >
Date Tue, 14 Nov 2006 06:14:03 GMT
Thank you. Will this patch go into the trunk eventually?

Rice

On 11/13/06, Mark Lundquist <ml@wrinkledog.com> 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