org.apache.cocoon.forms.util
Class JavaScriptHelper

java.lang.Object
  extended byorg.apache.cocoon.forms.util.JavaScriptHelper

public class JavaScriptHelper
extends Object

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

Version:
$Id: JavaScriptHelper.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Constructor Summary
JavaScriptHelper()
           
 
Method Summary
static org.mozilla.javascript.Function buildFunction(Element element, String name, 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(Map objectModel)
          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 name,
                                                            String[] argumentNames)
                                                     throws IOException
Build a function with the content of a DOM element.

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

getRootScope

public static org.mozilla.javascript.Scriptable getRootScope(Map objectModel)
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 - the object model 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-2008 The Apache Software Foundation. All Rights Reserved.