public class Scopes
extends java.lang.Object
Scope
).Constructor and Description |
---|
Scopes() |
Modifier and Type | Method and Description |
---|---|
static void |
afterInterpret()
Used with
beforeInterpret(org.zkoss.zk.ui.ext.Scope) to clean up implicit
variables. |
static Scope |
beforeInterpret(Scope scope)
Prepares implicit variable before calling
Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.ui.ext.Scope) . |
static Scope |
getCurrent(Page page)
Returns the current scope.
|
static java.lang.Object |
getImplicit(java.lang.String name,
java.lang.Object defValue)
Returns the implicit object.
|
static void |
setImplicit(java.lang.String name,
java.lang.Object value)
Sets an implicit object.
|
public static final Scope beforeInterpret(Scope scope)
Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.ui.ext.Scope)
.
Typical use:
final Scope scope = Scopes.beforeInterpret(comp);
try {
Scopes.setImplicit("some", value);
page.interpret(zslang, zscript, scope); //it will push scope as the current scope
} finally {
Scopes.afterInterpret();
}
Another example:
Scopes.beforeInterpret(comp);
try {
constr.validate(comp); //if constr might be an instance of a class implemented in zscript
} finally {
Scopess.afterInterpret();
}
If you need to set some implicit variables, you can invoke
setImplicit(java.lang.String, java.lang.Object)
between beforeInterpret(org.zkoss.zk.ui.ext.Scope)
and afterInterpret()
.
scope
- the scope, never null.public static final void afterInterpret()
beforeInterpret(org.zkoss.zk.ui.ext.Scope)
to clean up implicit
variables.public static void setImplicit(java.lang.String name, java.lang.Object value)
beforeInterpret(org.zkoss.zk.ui.ext.Scope)
and
afterInterpret()
.public static java.lang.Object getImplicit(java.lang.String name, java.lang.Object defValue)
It searches the implicit object stored with setImplicit(java.lang.String, java.lang.Object)
,
and also searches the system implicit objects by use of
Components.getImplicit(Page, Component, String)
.
name
- the variable to retrievedefValue
- the default vale that is used if the implicit
object is not defined.public static final Scope getCurrent(Page page)
Event.getTarget()
.
Otherwise, the scope of the page specified is assumed.
This method is used only to implement Interpreter
.
You rarely need to access it other than implementing an interpreter.
page
- the page. It is used if beforeInterpret(org.zkoss.zk.ui.ext.Scope)
is not called before. If null, the current page (ExecutionCtrl.getCurrentPage()
is assumed.Copyright © 2005-2011 Potix Corporation. All Rights Reserved.