org.apache.cocoon.woody.util
Class JavaScriptHelper

java.lang.Object
  extended by org.apache.cocoon.woody.util.JavaScriptHelper

public class JavaScriptHelper
extends Object

Helper methods to use JavaScript in various locations of the Woody configuration files such as event listeners and bindings.

Version:
CVS $Id: JavaScriptHelper.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Sylvain Wallez

Constructor Summary
JavaScriptHelper()
           
 
Method Summary
static org.mozilla.javascript.Function buildFunction(Element element, String[] argumentNames)
          Build a function with the content of a DOM element.
static org.mozilla.javascript.Script buildScript(Element element)
          Build a script with the content of a DOM element.
static Object callFunction(org.mozilla.javascript.Function func, Object thisObject, Object[] arguments, Map objectModel)
           
static Object execScript(org.mozilla.javascript.Script script, Map values, Map objectModel)
           
static org.mozilla.javascript.Scriptable getParentScope(Map objectModel)
          Get a parent scope for building a child scope.
static org.mozilla.javascript.Scriptable getRootScope()
          Get a root scope for building child scopes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptHelper

public JavaScriptHelper()
Method Detail

buildScript

public static org.mozilla.javascript.Script buildScript(Element element)
                                                 throws IOException
Build a script with the content of a DOM element.

Parameters:
element - the element containing the script
Returns:
the compiled script
Throws:
IOException

buildFunction

public static org.mozilla.javascript.Function buildFunction(Element element,
                                                            String[] argumentNames)
                                                     throws IOException
Build a function with the content of a DOM element.

Parameters:
element - the element containing the function body
argumentNames - names of the function arguments
Returns:
the compiled function
Throws:
IOException

getRootScope

public static org.mozilla.javascript.Scriptable getRootScope()
Get a root scope for building child scopes.

Returns:
an appropriate root scope

getParentScope

public static org.mozilla.javascript.Scriptable getParentScope(Map objectModel)
Get a parent scope for building a child scope. The request is searched for an existing scope that can be provided by a flowscript higher in the call stack, giving visibility to flowscript functions and global (session) variables.

Parameters:
objectModel - an objectModel where the flowscript scope will be searched (can be null).
Returns:
an appropriate parent scope.

execScript

public static Object execScript(org.mozilla.javascript.Script script,
                                Map values,
                                Map objectModel)
                         throws org.mozilla.javascript.JavaScriptException
Throws:
org.mozilla.javascript.JavaScriptException

callFunction

public static Object callFunction(org.mozilla.javascript.Function func,
                                  Object thisObject,
                                  Object[] arguments,
                                  Map objectModel)
                           throws org.mozilla.javascript.JavaScriptException
Throws:
org.mozilla.javascript.JavaScriptException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.