org.zkoss.zk.scripting
Class Namespaces

java.lang.Object
  extended by org.zkoss.zk.scripting.Namespaces

public class Namespaces
extends java.lang.Object

Namespace relevant utilities.

Author:
tomyeh

Constructor Summary
Namespaces()
           
 
Method Summary
static void afterInterpret()
          Used with beforeInterpret(org.zkoss.zk.ui.Component) to clean up implicit variables.
static void afterInterpret(java.util.Map backup, Namespace ns, boolean popNS)
          Deprecated. As of release 3.6.1, it is replaced with afterInterpret().
static void backupVariable(java.util.Map backup, Namespace ns, java.lang.String name)
          Deprecated. As of release 3.6.1, it is replaced with setImplicit(java.lang.String, java.lang.Object).
static Namespace beforeInterpret(Component comp)
          Prepares implicit variable before calling Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace).
static Namespace beforeInterpret(java.util.Map backup, Component comp, boolean pushNS)
          Deprecated. As of release 3.6.1, it is replaced with beforeInterpret(Component).
static Namespace beforeInterpret(java.util.Map backup, Page page, boolean pushNS)
          Deprecated. As of release 3.6.1, it is replaced with beforeInterpret(Page).
static Namespace beforeInterpret(Page page)
          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.
static java.lang.Object getImplicit(java.lang.String name, java.lang.Object defValue)
          Returns the implict object.
static void setImplicit(java.lang.String name, java.lang.Object value)
          Sets an implicit object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Namespaces

public Namespaces()
Method Detail

beforeInterpret

public static final Namespace beforeInterpret(Component comp)
Prepares implicit variable before calling Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace).

Typical use:


final Namespace ns = Namespaces.beforeInterpret(comp);
try {
  Namespaces.setImplicit("some", value);
  page.interpret(zslang, zscript, ns); //it will push ns as the current namespace
} finally {
  Namespaces.afterInterpret();
}

Another example:


Namespaces.beforeInterpret(comp);
try {
  constr.validate(comp); //if constr might be an instance of a class implemented in zscript
} finally {
  Namespaces.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.Component) and afterInterpret().

Parameters:
comp - the component, never null.
Returns:
the namespace that owns the specified component
Since:
3.6.1

beforeInterpret

public static final Namespace beforeInterpret(Page page)
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.

Parameters:
page - the page, never null.
Returns:
the namespace that owns the specified page
Since:
3.6.1
See Also:
beforeInterpret(Component)

afterInterpret

public static final void afterInterpret()
Used with beforeInterpret(org.zkoss.zk.ui.Component) to clean up implicit variables.

Since:
3.6.1

setImplicit

public static void setImplicit(java.lang.String name,
                               java.lang.Object value)
Sets an implicit object. It can be called only between beforeInterpret(org.zkoss.zk.ui.Component) and afterInterpret().

Since:
3.6.1

getImplicit

public static java.lang.Object getImplicit(java.lang.String name,
                                           java.lang.Object defValue)
Returns the implict object.

Parameters:
name - the variable to retrieve
defValue - the default vale that is used if the implicit object is not defined.
Since:
3.6.1

beforeInterpret

public static final Namespace beforeInterpret(java.util.Map backup,
                                              Component comp,
                                              boolean pushNS)
Deprecated. As of release 3.6.1, it is replaced with beforeInterpret(Component).


beforeInterpret

public static final Namespace beforeInterpret(java.util.Map backup,
                                              Page page,
                                              boolean pushNS)
Deprecated. As of release 3.6.1, it is replaced with beforeInterpret(Page).


afterInterpret

public static final void afterInterpret(java.util.Map backup,
                                        Namespace ns,
                                        boolean popNS)
Deprecated. As of release 3.6.1, it is replaced with afterInterpret().


backupVariable

public static final void backupVariable(java.util.Map backup,
                                        Namespace ns,
                                        java.lang.String name)
Deprecated. As of release 3.6.1, it is replaced with setImplicit(java.lang.String, java.lang.Object).


getCurrent

public static final Namespace getCurrent(Page page)
Returns the current namespace. The current namespace is the event target's namespace if this thread is processing an event (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.



Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo