org.odlabs.wiquery.core.javascript
Class JsScope

java.lang.Object
  extended by org.odlabs.wiquery.core.javascript.JsScope
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AjaxDialogButton.AjaxDialogScope, JsScopeEvent, JsScopePositionEvent, JsScopeUiDatePickerDateTextEvent, JsScopeUiDatePickerEvent, JsScopeUiDatePickerOnChangeEvent, JsScopeUiEvent

public abstract class JsScope
extends Object
implements Serializable

$Id$

JsScope are used to define anonymous JavaScript functions. For example, let's take the each statement:

        
 new JsQuery().$(".foo").each(new JsScope() {
 
        public void execute(JsScopeContext scopeContext) {
                scopeContext.self().chain("css", "border", "1px solid red");
        }
 
 });
 
 

You can either pass arguments to the JsScope (like in JavaScript functions) (see constructor args).

Since:
0.7
Author:
Lionel Armanet
See Also:
JsStatement, JsScopeContext, Serialized Form

Constructor Summary
JsScope(String... scopeParameters)
          Constructs a new JsScope instance with the given args.
 
Method Summary
protected abstract  void execute(JsScopeContext scopeContext)
          Executes the JsScope.
static JsScope quickScope(CharSequence javascriptCode)
          Creates a default JsScope to execute the given statement.
static JsScope quickScope(JsStatement jsStatement)
          Creates a default JsScope to execute the given statement.
 CharSequence render()
          Renders the scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsScope

public JsScope(String... scopeParameters)
Constructs a new JsScope instance with the given args. This is the equivalent of the JavaScript statement: function(arg1, arg2, arg3) {

Parameters:
scopeParameters -
Method Detail

quickScope

public static JsScope quickScope(CharSequence javascriptCode)
Creates a default JsScope to execute the given statement.

Parameters:
javascriptCode - the JavaScript statement to execute with the scope.
Returns:
the created JsScope.

quickScope

public static JsScope quickScope(JsStatement jsStatement)
Creates a default JsScope to execute the given statement.

Parameters:
jsStatement - the JavaScript statement to execute with the scope.
Returns:
the created JsScope.

execute

protected abstract void execute(JsScopeContext scopeContext)
Executes the JsScope.

Parameters:
scopeContext - the given scope.

render

public CharSequence render()
Renders the scope.



Copyright © 2012. All Rights Reserved.