|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.scripting.Namespaces
public class Namespaces
Namespace relevant utilities.
| Constructor Summary | |
|---|---|
Namespaces()
|
|
| Method Summary | |
|---|---|
static void |
afterInterpret(java.util.Map backup,
Namespace ns,
boolean popNS)
Used with beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean) to clean up builtin
variables. |
static void |
backupVariable(java.util.Map backup,
Namespace ns,
java.lang.String name)
Backup the specfied variable, such that it can be restored with afterInterpret(java.util.Map, org.zkoss.zk.scripting.Namespace, boolean). |
static Namespace |
beforeInterpret(java.util.Map backup,
Component comp,
boolean pushNS)
Prepares builtin variable before calling Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace). |
static Namespace |
beforeInterpret(java.util.Map backup,
Page page,
boolean pushNS)
Prepares builtin variable before calling Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace) or a method that might be
implemented with zscript. |
static Namespace |
getCurrent(Page page)
Returns the current namespace. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Namespaces()
| Method Detail |
|---|
public static final Namespace beforeInterpret(java.util.Map backup,
Component comp,
boolean pushNS)
Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace).
Typical use:
final Map backup = new HashMap();
final Namespace ns = Namespaces.beforeInterpret(backup, comp, false);
try {
Namespaces.backupVariable(backup, ns, "some");
page.interpret(zslang, zscript, ns); //it will push ns as the current namespace
} finally {
Namespaces.afterInterpret(backup, ns, false);
}
Another example:
final Map backup = new HashMap();
final Namespace ns = Namespaces.beforeInterpret(backup, comp, true);
try {
Namespaces.backupVariable(backup, ns, "some");
constr.validate(comp); //if constr might be an instance of a class implemented in zscript
} finally {
Namespaces.afterInterpret(backup, ns, true);
}
If you need to backup some variables, you can invoke
backupVariable(java.util.Map, org.zkoss.zk.scripting.Namespace, java.lang.String) between beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean)
and afterInterpret(java.util.Map, org.zkoss.zk.scripting.Namespace, boolean).
backup - the map to hold the backup variables. Never null.comp - the component, never null.pushNS - whether to make the namespace being returned
as the current namespace (getCurrent(org.zkoss.zk.ui.Page)).
Note: its value must be the same as the popNS argument of
afterInterpret(java.util.Map, org.zkoss.zk.scripting.Namespace, boolean).
public static final Namespace beforeInterpret(java.util.Map backup,
Page page,
boolean pushNS)
Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace) or a method that might be
implemented with zscript.
backup - the map to hold the backup variables. Never null.page - the page, never null.pushNS - whether to make the namespace being returned
as the current namespace (getCurrent(org.zkoss.zk.ui.Page)).
Note: its value must be the same as the popNS argument of
afterInterpret(java.util.Map, org.zkoss.zk.scripting.Namespace, boolean).
beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean)
public static final void afterInterpret(java.util.Map backup,
Namespace ns,
boolean popNS)
beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean) to clean up builtin
variables.
backup - the map to hold the backup variables. Never null.
It must be the same as the backup argument of beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean).ns - the namespace returned by beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean)popNS - whether to pop out the current namespace.
Its value must be the same as the pushNS argument of beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean).
public static final void backupVariable(java.util.Map backup,
Namespace ns,
java.lang.String name)
afterInterpret(java.util.Map, org.zkoss.zk.scripting.Namespace, boolean).
Note: you have to invoke beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean) before calling
this method. Then, backup-ed variables will be restored together
when afterInterpret(java.util.Map, org.zkoss.zk.scripting.Namespace, boolean) is called.
backup - the map to hold the backup variables. Never null.
It must be the same as the backup argument of beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean).name - the variable to backup.public static final Namespace getCurrent(Page page)
Event.getTarget().
Otherwise, the namespace 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||