Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cocoon.forms.util
Class JavaScriptHelper

    java.lang.Object
      org.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.java 587759 2007-10-24 03:00:37Z vgritsenko $

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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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