org.zkoss.zk.ui.impl
Class PageImpl

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractPage
      extended by org.zkoss.zk.ui.impl.PageImpl
All Implemented Interfaces:
java.io.Serializable, Scope, IdSpace, Page, PageCtrl

public class PageImpl
extends AbstractPage
implements java.io.Serializable

An implmentation of Page and PageCtrl. Refer to them for more details.

Note: though PageImpl is serializable, it is designed to work with Web container to enable the serialization of sessions. It is not suggested to serialize and desrialize it directly since many fields might be lost.

On the other hand, it is OK to serialize and deserialize Component.

Implementation Notes:
It is not thread-safe because it is protected by the spec: at most one thread can access a page and all its components at the same time.

Author:
tomyeh
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.zkoss.zk.ui.Page
APPLICATION_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.PageCtrl
ATTR_REDRAW_BY_INCLUDE
 
Constructor Summary
PageImpl(LanguageDefinition langdef, ComponentDefinitionMap compdefs, java.lang.String path, java.lang.String zslang)
          Constructs a page without page definition and richlet.
PageImpl(PageDefinition pgdef)
          Constructs a page by giving the page definition.
PageImpl(Richlet richlet, java.lang.String path)
          Constructs a page by specifying a richlet.
 
Method Summary
 void addDeferredZScript(Component parent, ZScript zscript)
          Adds a deferred zscript.
 boolean addEventListener(java.lang.String evtnm, EventListener listener)
          Adds an event listener to specified event for all components in this page.
 void addFunctionMapper(FunctionMapper mapper)
          Adds the function mapper in addition to the current one.
 boolean addScopeListener(ScopeListener listener)
          Adds a listener to listen whether this scope is changed.
 boolean addVariableResolver(VariableResolver resolver)
          Adds a name resolver that will be used to resolve a variable by Page.getVariable(java.lang.String).
 boolean containsVariable(java.lang.String name)
          Deprecated. As of release 5.0.0, replaced with hasAttribute(java.lang.String, int).
 void destroy()
          Called when this page is about to be detroyed.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the specified attribute associated with this page.
 java.lang.Object getAttribute(java.lang.String name, boolean recurse)
          Returns the custom attribute associated with this object.
 java.lang.Object getAttribute(java.lang.String name, int scope)
          Returns the value of the specified custom attribute in the specified scope.
 java.lang.Object getAttributeOrFellow(java.lang.String name, boolean recurse)
          Returns the custom attribute associated with this page, or the fellow of this page; or null if no found.
 java.util.Map getAttributes()
          Returns all custom attributes associated with this page.
 java.util.Map getAttributes(int scope)
          Returns all custom attributes of the specified scope.
 java.lang.Boolean getAutomaticTimeout()
          Returns whether to automatically redirect to the timeout URI.
 java.lang.Boolean getCacheable()
          Returns if the client can cache the rendered result, or null to use the device default.
 ComponentDefinition getComponentDefinition(java.lang.Class cls, boolean recurse)
          Returns the component definition of the specified class, or null if not found.
 ComponentDefinition getComponentDefinition(java.lang.String name, boolean recurse)
          Returns the component definition of the specified name, or null if not found.
 ComponentDefinitionMap getComponentDefinitionMap()
          Returns the map of component definitions (never null).
 java.lang.String getContentType()
          Returns the content type, or null to use the device default.
 Component getDefaultParent()
          Deprecated. As of release 5.0.0, the default parent is no longe meaningful.
 Desktop getDesktop()
          Returns the desktop that this page belongs to.
 java.lang.String getDocType()
          Returns the doc type (<!
 java.lang.Class getExpressionFactoryClass()
          Returns the implementation of the expression factory that is used by this page, or null if Configuration.getExpressionFactoryClass() is used.
 java.lang.String getFirstLine()
          Returns the first line to be generated to the output, or null if nothing to generate.
 FunctionMapper getFunctionMapper()
          Returns the function mapper for resolving XEL functions, or null if not available.
 java.lang.String getHeaders()
          Returns all content that will be generated inside the header element (never null).
 java.lang.String getHeaders(boolean before)
          Returns the content of the specified condition that shall be generated inside the header element (never null).
 java.lang.String getId()
          Returns ID which is unique in the request (never null).
 Interpreter getInterpreter(java.lang.String zslang)
          Returns the interpreter of the specified scripting language.
 LanguageDefinition getLanguageDefinition()
          Returns the language definition that this page belongs to (never null).
 java.util.Iterator getListenerIterator(java.lang.String evtnm)
          Returns an iterator for iterating listener for the specified event.
 java.util.Collection getLoadedInterpreters()
          Returns all loaded interpreters.
 Namespace getNamespace()
          Deprecated. As of release 5.0.0, the concept of namespace is deprecated and replaced with the attributes of a scope (such as a page and a component).
 Component getOwner()
          Returns the owner of this page, or null if it is not owned by any component.
 java.lang.String getRequestPath()
          Returns the request path of this page, or "" if not available.
 java.lang.String getRootAttributes()
          Returns the attributes of the root element declared in this page (never null).
 java.lang.String getStyle()
          Returns the CSS style of this page, or empty if not specified.
 java.lang.String getTitle()
          Returns the title of the desktop this page belongs to (and evaluate it if it contains an expression).
 java.lang.String getUuid()
          Returns UUID (universal unique ID) which is unquie in the whole session.
 java.lang.Object getVariable(java.lang.String name)
          Deprecated. As of release 5.0.0, replaced with getAttribute(java.lang.String, int).
 java.lang.Object getXelVariable(java.lang.String name)
          Returns a variable that is visible to XEL expressions.
 java.lang.Object getXelVariable(XelContext ctx, java.lang.Object base, java.lang.Object name, boolean ignoreExec)
          Returns a vairable that is visible to XEL expressions.
 java.lang.Class getZScriptClass(java.lang.String clsnm)
          Returns the class of the specified name by searching the thread class loader and the classes defined in the loaded interpreters.
 Function getZScriptFunction(Component comp, java.lang.String name, java.lang.Class[] argTypes)
          Returns the function of the specified name by searching the logical scope of the specified component in all the loaded interpreters.
 Function getZScriptFunction(Namespace ns, java.lang.String name, java.lang.Class[] argTypes)
          Deprecated. As of release 5.0.0, replaced with getZScriptFunction(Component,String,Class[]).
 Function getZScriptFunction(java.lang.String name, java.lang.Class[] argTypes)
          Returns the function of the specified name by searching the loaded interpreters.
 java.lang.String getZScriptLanguage()
          Returns the default scripting language which is assumed when a zscript element doesn't specify any language.
 java.lang.Object getZScriptVariable(Component comp, java.lang.String name)
          Returns the value of the variable of the specified name by searching the logical scope of the specified component in all the loaded interpreters, if any.
 java.lang.Object getZScriptVariable(Namespace ns, java.lang.String name)
          Deprecated. As of release 5.0.0, replaced with getZScriptVariable(Component,String).
 java.lang.Object getZScriptVariable(java.lang.String name)
          Returns the value of the variable of the specified name by searching the loaded interpreters, if any.
 boolean hasAttribute(java.lang.String name)
          Returns if an attribute exists.
 boolean hasAttribute(java.lang.String name, boolean recurse)
          Returns if a custom attribute is associated with this object.
 boolean hasAttribute(java.lang.String name, int scope)
          Returns if an attribute exists.
 boolean hasAttributeOrFellow(java.lang.String name, boolean recurse)
          Returns if a custom attribute is associated with this page, or a fellow of this page.
protected  void init()
          Initialized the page when contructed or deserialized.
 void init(PageConfig config)
          Initializes this page by assigning the info provided by the specified PageConfig, and then adds it to a desktop (by use of Execution.getDesktop()).
 void interpret(java.lang.String zslang, java.lang.String script, Namespace ns)
          Deprecated. As of release 5.0.0, replaced with interpret(String,String,Scope).
 void interpret(java.lang.String zslang, java.lang.String script, Scope scope)
          Interprets a script in the sepcified scripting language in the context of the specified scope.
 void invalidate()
          Invalidates this page to cause all components to redraw.
 boolean isComplete()
          Returns if this page is a complete page.
 boolean isListenerAvailable(java.lang.String evtnm)
          Returns whether the event listener is available.
 void preInit()
          Pre-initializes this page.
 void redraw(java.io.Writer out)
          Redraws the whole page into the specified output.
 java.lang.Object removeAttribute(java.lang.String name)
          Removes the specified attribute custom associated with the page.
 java.lang.Object removeAttribute(java.lang.String name, boolean recurse)
          Removes the custom attribute associated with this scope.
 java.lang.Object removeAttribute(java.lang.String name, int scope)
          Removes the specified custom attribute in the specified scope.
 boolean removeEventListener(java.lang.String evtnm, EventListener listener)
          Removes an event listener.
 boolean removeScopeListener(ScopeListener listener)
          Removes a change listener from this scope.
 boolean removeVariableResolver(VariableResolver resolver)
          Removes a name resolve that was added by Page.addVariableResolver(org.zkoss.xel.VariableResolver).
 java.lang.Class resolveClass(java.lang.String clsnm)
          Resolves the class of the specified name.
 void sessionDidActivate(Desktop desktop)
          Notification that the session, which owns this page, has just been activated (aka., deserialized).
 void sessionWillPassivate(Desktop desktop)
          Notification that the session, which owns this page, is about to be passivated (aka., serialized).
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
          Sets the value of the specified custom attribute associated with this page.
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object value, boolean recurse)
          Sets the custom attribute associated with this scope, or the parent scope.
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object value, int scope)
          Sets the value of the specified custom attribute in the specified scope.
 void setAutomaticTimeout(java.lang.Boolean autoTimeout)
          Sets whether to automatically redirect to the timeout URI.
 void setCacheable(java.lang.Boolean cacheable)
          Sets if the client can cache the rendered result.
 void setComplete(boolean complete)
          Sets if the page is a complete page.
 void setContentType(java.lang.String contentType)
          Sets the content type.
 void setDefaultParent(Component comp)
          Deprecated. As of release 5.0.0, the default parent is no longe meaningful.
 void setDocType(java.lang.String docType)
          Sets the doc type (<!
 void setExpressionFactoryClass(java.lang.Class expfcls)
          Sets the implementation of the expression factory that is used by this page.
 void setFirstLine(java.lang.String firstLine)
          Sets the first line to be generated to the output.
 void setId(java.lang.String id)
          Sets the identifier of this page.
 void setOwner(Component comp)
          Sets the owner of this page.
 void setRootAttributes(java.lang.String rootAttrs)
          Set the attributes of the root element declared in this page Default: "".
 void setStyle(java.lang.String style)
          Sets the CSS style of this page.
 void setTitle(java.lang.String title)
          Sets the title of the desktop this page belongs to (it might contain an expression).
 void setVariable(java.lang.String name, java.lang.Object val)
          Deprecated. As of release 5.0.0, replaced with setAttribute(java.lang.String, java.lang.Object, int).
 void setZScriptLanguage(java.lang.String zslang)
          Sets the defafult scripting language which will be assumed if a zscript element doesn't specify any language.
 java.lang.String toString()
           
 void unsetVariable(java.lang.String name)
          Deprecated. As of release 5.0.0, replaced with removeAttribute(java.lang.String, int).
 
Methods inherited from class org.zkoss.zk.ui.AbstractPage
getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstRoot, getLastRoot, getRoots, hasFellow, hasFellow, removeComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageImpl

public PageImpl(PageDefinition pgdef)
Constructs a page by giving the page definition.

Note: when a page is constructed, it doesn't belong to a desktop yet. Caller has to invoke init() to complete the creation of a page. Why two phase? Contructor could be called before execution is activated, but init() must be called in an execution.

Also note that getId() and getTitle() are not ready until init() is called.

Parameters:
pgdef - the page definition (never null).

PageImpl

public PageImpl(LanguageDefinition langdef,
                ComponentDefinitionMap compdefs,
                java.lang.String path,
                java.lang.String zslang)
Constructs a page without page definition and richlet.

Parameters:
langdef - the language definition (never null)
compdefs - the component definition map. If null, an empty map is assumed.
path - the request path. If null, empty is assumed.
zslang - the zscript language. If null, "Java" is assumed.

PageImpl

public PageImpl(Richlet richlet,
                java.lang.String path)
Constructs a page by specifying a richlet.

Note: when a page is constructed, it doesn't belong to a desktop yet. Caller has to invoke init() to complete the creation of a page.

Also note that getId() and getTitle() are not ready until init() is called.

Parameters:
richlet - the richlet to serve this page.
path - the request path, or null if not available
Method Detail

init

protected void init()
Initialized the page when contructed or deserialized.


getFunctionMapper

public final FunctionMapper getFunctionMapper()
Description copied from interface: Page
Returns the function mapper for resolving XEL functions, or null if not available.

Specified by:
getFunctionMapper in interface Page

addFunctionMapper

public void addFunctionMapper(FunctionMapper mapper)
Description copied from interface: Page
Adds the function mapper in addition to the current one.

The new added function mapper has the higher priority. Page.getFunctionMapper() will return the new

Specified by:
addFunctionMapper in interface Page
Parameters:
mapper - the new function mapper (null to ignore).

getRequestPath

public java.lang.String getRequestPath()
Description copied from interface: Page
Returns the request path of this page, or "" if not available.

It is the same as the servlet path (javax.servlet.http.HttpServletRequest's getServletPath), if ZK is running at a servlet container.

Note: Desktop.getRequestPath() returns the request path that causes the desktop to create. And, there might be multiple pages in the same desktop.

Specified by:
getRequestPath in interface Page
See Also:
Execution.getContextPath(), Desktop.getRequestPath()

getId

public final java.lang.String getId()
Description copied from interface: Page
Returns ID which is unique in the request (never null).

Note: it returns null when Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map) is called.

Specified by:
getId in interface Page

getUuid

public final java.lang.String getUuid()
Description copied from interface: Page
Returns UUID (universal unique ID) which is unquie in the whole session. The UUID is generated automatically and immutable.

It is mainly used for communication between client and server and you rarely need to access it.

Specified by:
getUuid in interface Page

setId

public void setId(java.lang.String id)
Description copied from interface: Page
Sets the identifier of this page.

Note: you can change the page's ID only in Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map) or ExecutionInit.init(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Execution). Once the page is initialized (by PageCtrl.init(org.zkoss.zk.ui.sys.PageConfig)), calling this method will cause an exception.

Specified by:
setId in interface Page

getTitle

public java.lang.String getTitle()
Description copied from interface: Page
Returns the title of the desktop this page belongs to (and evaluate it if it contains an expression).

Default: "".

Specified by:
getTitle in interface Page

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: Page
Sets the title of the desktop this page belongs to (it might contain an expression).

Specified by:
setTitle in interface Page

getStyle

public java.lang.String getStyle()
Description copied from interface: Page
Returns the CSS style of this page, or empty if not specified.

Specified by:
getStyle in interface Page

setStyle

public void setStyle(java.lang.String style)
Description copied from interface: Page
Sets the CSS style of this page.

Note: Unlike Page.setTitle(java.lang.String), you can change the style only in the lifecycle of the loading page.

Specified by:
setStyle in interface Page

getAttributes

public java.util.Map getAttributes(int scope)
Description copied from interface: Page
Returns all custom attributes of the specified scope. You could reference them directly, or thru componentScope, spaceScope, pageScope, requestScope and desktopScope in zscript and EL.

If scope is Page.PAGE_SCOPE, it means custom attributes shared by components from the same page as this one's.

If scope is Page.DESKTOP_SCOPE, it means custom attributes shared by components from the same desktopas this one's.

Specified by:
getAttributes in interface Page
Parameters:
scope - Page.APPLICATION_SCOPE, Page.SESSION_SCOPE, Page.PAGE_SCOPE, Page.REQUEST_SCOPE or Page.DESKTOP_SCOPE.

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     int scope)
Description copied from interface: Page
Returns the value of the specified custom attribute in the specified scope.

If scope is Page.PAGE_SCOPE, it means custom attributes shared by components from the same page as this one's.

If scope is Page.DESKTOP_SCOPE, it means custom attributes shared by components from the same desktopas this one's.

Specified by:
getAttribute in interface Page
scope - Page.APPLICATION_SCOPE, Page.SESSION_SCOPE, Page.PAGE_SCOPE, Page.REQUEST_SCOPE or Page.DESKTOP_SCOPE.

hasAttribute

public boolean hasAttribute(java.lang.String name,
                            int scope)
Description copied from interface: Page
Returns if an attribute exists.

Notice that null is a valid value, so you need this method to really know if an atribute is defined.

Specified by:
hasAttribute in interface Page

setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object value,
                                     int scope)
Description copied from interface: Page
Sets the value of the specified custom attribute in the specified scope.

If scope is Page.PAGE_SCOPE, it means custom attributes shared by components from the same page as this one's.

If scope is Page.DESKTOP_SCOPE, it means custom attributes shared by components from the same desktopas this one's.

Specified by:
setAttribute in interface Page
scope - Page.APPLICATION_SCOPE, Page.SESSION_SCOPE, Page.PAGE_SCOPE, Page.REQUEST_SCOPE or Page.DESKTOP_SCOPE.

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name,
                                        int scope)
Description copied from interface: Page
Removes the specified custom attribute in the specified scope.

If scope is Page.PAGE_SCOPE, it means custom attributes shared by components from the same page as this one's.

If scope is Page.DESKTOP_SCOPE, it means custom attributes shared by components from the same desktopas this one's.

Specified by:
removeAttribute in interface Page
scope - Page.APPLICATION_SCOPE, Page.SESSION_SCOPE, Page.PAGE_SCOPE, Page.REQUEST_SCOPE or Page.DESKTOP_SCOPE.

getAttributes

public java.util.Map getAttributes()
Description copied from interface: Page
Returns all custom attributes associated with this page.

Specified by:
getAttributes in interface Scope
Specified by:
getAttributes in interface Page

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: Page
Returns the value of the specified attribute associated with this page.

Specified by:
getAttribute in interface Scope
Specified by:
getAttribute in interface Page

hasAttribute

public boolean hasAttribute(java.lang.String name)
Description copied from interface: Page
Returns if an attribute exists.

Notice that null is a valid value, so you need this method to really know if an atribute is defined.

Specified by:
hasAttribute in interface Scope
Specified by:
hasAttribute in interface Page

setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object value)
Description copied from interface: Page
Sets the value of the specified custom attribute associated with this page.

Specified by:
setAttribute in interface Scope
Specified by:
setAttribute in interface Page
value - the value.
Returns:
the previous value associated with the attribute, if any

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface: Page
Removes the specified attribute custom associated with the page.

Specified by:
removeAttribute in interface Scope
Specified by:
removeAttribute in interface Page
Returns:
the previous value associated with the attribute, if any,

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     boolean recurse)
Description copied from interface: Scope
Returns the custom attribute associated with this object.

Specified by:
getAttribute in interface Scope
recurse - whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.

hasAttribute

public boolean hasAttribute(java.lang.String name,
                            boolean recurse)
Description copied from interface: Scope
Returns if a custom attribute is associated with this object.

Notice that null is a valid value, so you can tell if an attribute is assoicated by examining the return value of Scope.getAttribute(java.lang.String).

Specified by:
hasAttribute in interface Scope
recurse - whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.

setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object value,
                                     boolean recurse)
Description copied from interface: Scope
Sets the custom attribute associated with this scope, or the parent scope.

Specified by:
setAttribute in interface Scope
recurse - whether to look up the parent scope for the existence of the attribute.
If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is replaced. Otherwise, it is the same as Scope.setAttribute(String,Object).

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name,
                                        boolean recurse)
Description copied from interface: Scope
Removes the custom attribute associated with this scope.

Specified by:
removeAttribute in interface Scope
recurse - whether to look up the parent scope for the existence of the attribute.
If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is removed. Otherwise, it is the same as Scope.removeAttribute(String).

getAttributeOrFellow

public java.lang.Object getAttributeOrFellow(java.lang.String name,
                                             boolean recurse)
Description copied from interface: Page
Returns the custom attribute associated with this page, or the fellow of this page; or null if no found.

Notice that this method will NOT check for any variable defined in the variable resolver (Page.addVariableResolver(org.zkoss.xel.VariableResolver)). You have to invoke Page.getXelVariable(XelContext,Object,Object,boolean) or Page.getXelVariable(String) manually.

Specified by:
getAttributeOrFellow in interface Page
recurse - whether to look up the desktop/session for the existence of the attribute.

hasAttributeOrFellow

public boolean hasAttributeOrFellow(java.lang.String name,
                                    boolean recurse)
Description copied from interface: Page
Returns if a custom attribute is associated with this page, or a fellow of this page.

Notice that this method will NOT check for any variable defined in the variable resolver (Page.addVariableResolver(org.zkoss.xel.VariableResolver)). You have to invoke Page.getXelVariable(XelContext,Object,Object,boolean) or Page.getXelVariable(String) manually.

Specified by:
hasAttributeOrFellow in interface Page
recurse - whether to look up the desktop/session for the existence of the attribute.

addScopeListener

public boolean addScopeListener(ScopeListener listener)
Description copied from interface: Scope
Adds a listener to listen whether this scope is changed. The listener is called when a custom attribute is added, removed, or the parent is changed.

Specified by:
addScopeListener in interface Scope
Returns:
wether the listener is added successfully. Note: if the resolver was added before, it won't be added again and this method returns false.

removeScopeListener

public boolean removeScopeListener(ScopeListener listener)
Description copied from interface: Scope
Removes a change listener from this scope.

Specified by:
removeScopeListener in interface Scope
Returns:
false if listener is not added before.

invalidate

public void invalidate()
Description copied from interface: Page
Invalidates this page to cause all components to redraw.

Specified by:
invalidate in interface Page

resolveClass

public java.lang.Class resolveClass(java.lang.String clsnm)
                             throws java.lang.ClassNotFoundException
Description copied from interface: Page
Resolves the class of the specified name. It first looks at Classes and then all loaded interpreters Page.getLoadedInterpreters().

It is similar to Page.getZScriptClass(java.lang.String), except

  1. It searches the current thread's class loader first, and then, the loaded interpreters.
  2. It throws ClassNotFoundException if not found

Specified by:
resolveClass in interface Page
Throws:
java.lang.ClassNotFoundException
See Also:
Page.getZScriptClass(java.lang.String)

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object val)
Deprecated. As of release 5.0.0, replaced with setAttribute(java.lang.String, java.lang.Object, int).

Specified by:
setVariable in interface Page

containsVariable

public boolean containsVariable(java.lang.String name)
Deprecated. As of release 5.0.0, replaced with hasAttribute(java.lang.String, int).

Specified by:
containsVariable in interface Page

getVariable

public java.lang.Object getVariable(java.lang.String name)
Deprecated. As of release 5.0.0, replaced with getAttribute(java.lang.String, int).

Specified by:
getVariable in interface Page

unsetVariable

public void unsetVariable(java.lang.String name)
Deprecated. As of release 5.0.0, replaced with removeAttribute(java.lang.String, int).

Specified by:
unsetVariable in interface Page

getZScriptClass

public java.lang.Class getZScriptClass(java.lang.String clsnm)
Description copied from interface: Page
Returns the class of the specified name by searching the thread class loader and the classes defined in the loaded interpreters.

Note: if not defined in the interpeter, it will also look for the class by use of the current thread's class loader. See Page.resolveClass(java.lang.String).

Specified by:
getZScriptClass in interface Page
Returns:
the class, or null if not found
See Also:
Page.getLoadedInterpreters()

getZScriptFunction

public Function getZScriptFunction(java.lang.String name,
                                   java.lang.Class[] argTypes)
Description copied from interface: Page
Returns the function of the specified name by searching the loaded interpreters.

Specified by:
getZScriptFunction in interface Page
Returns:
the method, or null if not found
See Also:
Page.getLoadedInterpreters()

getZScriptFunction

public Function getZScriptFunction(Component comp,
                                   java.lang.String name,
                                   java.lang.Class[] argTypes)
Description copied from interface: Page
Returns the function of the specified name by searching the logical scope of the specified component in all the loaded interpreters.

Specified by:
getZScriptFunction in interface Page
Parameters:
comp - the component to start the search. If null, this method searches only the page's attributes. In other words, if comp is null, this method is the same as Page.getZScriptFunction(String, Class[]).

getZScriptFunction

public Function getZScriptFunction(Namespace ns,
                                   java.lang.String name,
                                   java.lang.Class[] argTypes)
Deprecated. As of release 5.0.0, replaced with getZScriptFunction(Component,String,Class[]).

Specified by:
getZScriptFunction in interface Page
Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the variable. It is ignored if the interpreter doesn't support hierachical scopes. Note: this method doesn't look for any variable stored in ns.
Returns:
the method, or null if not found
See Also:
Page.getLoadedInterpreters()

getZScriptVariable

public java.lang.Object getZScriptVariable(java.lang.String name)
Description copied from interface: Page
Returns the value of the variable of the specified name by searching the loaded interpreters, if any.

Specified by:
getZScriptVariable in interface Page
Returns:
the value of the variable, or null if not found
See Also:
Page.getLoadedInterpreters()

getZScriptVariable

public java.lang.Object getZScriptVariable(Component comp,
                                           java.lang.String name)
Description copied from interface: Page
Returns the value of the variable of the specified name by searching the logical scope of the specified component in all the loaded interpreters, if any.

Specified by:
getZScriptVariable in interface Page
Parameters:
comp - the component as the context to look for the variable defined in an interpreter. If null, the context is assumed to be this page.

getZScriptVariable

public java.lang.Object getZScriptVariable(Namespace ns,
                                           java.lang.String name)
Deprecated. As of release 5.0.0, replaced with getZScriptVariable(Component,String).

Specified by:
getZScriptVariable in interface Page
Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the variable. It is ignored if the interpreter doesn't support hierachical scopes. Note: this method doesn't look for any variable stored in ns.

getXelVariable

public java.lang.Object getXelVariable(java.lang.String name)
Description copied from interface: Page
Returns a variable that is visible to XEL expressions. It is a shortcut of getXelVariable(null, null, name, false).

This method is mainly used to access special variable, such as request parameters (if this page is requested by HTTP).

Specified by:
getXelVariable in interface Page
See Also:
Page.getXelVariable(XelContext, Object, Object, boolean)

getXelVariable

public java.lang.Object getXelVariable(XelContext ctx,
                                       java.lang.Object base,
                                       java.lang.Object name,
                                       boolean ignoreExec)
Description copied from interface: Page
Returns a vairable that is visible to XEL expressions.

Unlike Page.getXelVariable(String), this method can utilitize VariableResolverX introduced in ZK 5.0.

Specified by:
getXelVariable in interface Page
Parameters:
ctx - the XEL context
base - the base object. If null, it looks for a top-level variable. If not null, it looks for a member of the base object (such as getter).
name - the property to retrieve.
ignoreExec - whether to ignore the current execution (Execution.getVariableResolver(). If true, it invokes only the variable resolvers define in this page (Page.addVariableResolver(org.zkoss.xel.VariableResolver)). If false, it will first check the execution, so the implicit objects such as page and desktop will be resolved.
See Also:
Page.getXelVariable(String)

addVariableResolver

public boolean addVariableResolver(VariableResolver resolver)
Description copied from interface: Page
Adds a name resolver that will be used to resolve a variable by Page.getVariable(java.lang.String).

Note: the variables resolved by the specified resolver are accessible to both zscript and EL expressions.

Specified by:
addVariableResolver in interface Page
Returns:
wether the resolver is added successfully. Note: if the resolver was added before, it won't be added again and this method returns false.

removeVariableResolver

public boolean removeVariableResolver(VariableResolver resolver)
Description copied from interface: Page
Removes a name resolve that was added by Page.addVariableResolver(org.zkoss.xel.VariableResolver).

Specified by:
removeVariableResolver in interface Page
Returns:
false if resolved is not added before.

addEventListener

public boolean addEventListener(java.lang.String evtnm,
                                EventListener listener)
Description copied from interface: Page
Adds an event listener to specified event for all components in this page.

Due to performance consideration, unlike Component.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener), all event listeners for the page are deferrable, no matter Deferrable is implemented or not.

Specified by:
addEventListener in interface Page
Parameters:
evtnm - what event to listen (never null)
Returns:
whether the listener is added; false if it was added before.
See Also:
Component.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener)

removeEventListener

public boolean removeEventListener(java.lang.String evtnm,
                                   EventListener listener)
Description copied from interface: Page
Removes an event listener.

Specified by:
removeEventListener in interface Page
Returns:
whether the listener is removed; false if it was never added.

isComplete

public boolean isComplete()
Description copied from interface: Page
Returns if this page is a complete page. By complete we mean the page has everything that the client expects. For example, for HTML browsers, the page will generate the HTML, HEAD and BODY tags.

It is meaningful only if it is the top-level page (i.e., not included by the include component).

Default: false. It means ZK loader will enclose the page content with HTML/HEAD/BODY if necessary (such as not included by other Servlet).

If you have a page that has a complete HTML page and it is included by other page, you have to specify the complete flag to be true.

Specified by:
isComplete in interface Page

setComplete

public void setComplete(boolean complete)
Description copied from interface: Page
Sets if the page is a complete page.

Default: false. It means a page is complete if and only if it is not included by other page.

Specified by:
setComplete in interface Page
Parameters:
complete - whether the page is complete. If true, this page is assumed to be complete no matter it is included or not. If false, this page is assumed to be complete if it is not included by other page.
See Also:
Page.isComplete()

preInit

public void preInit()
Description copied from interface: PageCtrl
Pre-initializes this page. It initializes Page.getDesktop(), but it doesn't add this page to the desktop yet (which is done by PageCtrl.init(org.zkoss.zk.ui.sys.PageConfig)).

Note: it is called before Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map) and PageCtrl.init(org.zkoss.zk.ui.sys.PageConfig). Since Page.getDesktop() is initialized in this method, it is OK to create components in Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map).

Specified by:
preInit in interface PageCtrl

init

public void init(PageConfig config)
Description copied from interface: PageCtrl
Initializes this page by assigning the info provided by the specified PageConfig, and then adds it to a desktop (by use of Execution.getDesktop()).

Note: this method is called after PageCtrl.preInit() and Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map).

This method shall be called only after the current execution is activated.

Specified by:
init in interface PageCtrl
Parameters:
config - the info about how to initialize this page

destroy

public void destroy()
Description copied from interface: PageCtrl
Called when this page is about to be detroyed. It is called by desktop, after removing it from the desktop.

Specified by:
destroy in interface PageCtrl
Overrides:
destroy in class AbstractPage

getHeaders

public java.lang.String getHeaders(boolean before)
Description copied from interface: PageCtrl
Returns the content of the specified condition that shall be generated inside the header element (never null).

For HTML, the header element is the HEAD element.

Specified by:
getHeaders in interface PageCtrl
Parameters:
before - whether to return the headers that shall be shown before ZK's CSS/JS headers. If true, only the headers that shall be shown before (such as meta) are returned. If true, only the headers that shall be shown after (such as link) are returned.
See Also:
PageCtrl.getHeaders()

getHeaders

public java.lang.String getHeaders()
Description copied from interface: PageCtrl
Returns all content that will be generated inside the header element (never null).

For HTML, the header element is the HEAD element.

It returns all header no matter it shall be shown before or after ZK's CSS/JS headers. To have more control, use PageCtrl.getHeaders(boolean) instead.

Specified by:
getHeaders in interface PageCtrl
See Also:
PageCtrl.getHeaders(boolean)

getRootAttributes

public java.lang.String getRootAttributes()
Description copied from interface: PageCtrl
Returns the attributes of the root element declared in this page (never null). An empty string is returned if no special attribute is declared.

For HTML, the root element is the HTML element.

Specified by:
getRootAttributes in interface PageCtrl

setRootAttributes

public void setRootAttributes(java.lang.String rootAttrs)
Description copied from interface: PageCtrl
Set the attributes of the root element declared in this page

Default: "".

Specified by:
setRootAttributes in interface PageCtrl

getContentType

public java.lang.String getContentType()
Description copied from interface: PageCtrl
Returns the content type, or null to use the device default.

Specified by:
getContentType in interface PageCtrl

setContentType

public void setContentType(java.lang.String contentType)
Description copied from interface: PageCtrl
Sets the content type.

Specified by:
setContentType in interface PageCtrl

getDocType

public java.lang.String getDocType()
Description copied from interface: PageCtrl
Returns the doc type (<!DOCTYPE>), or null to use the device default.

Specified by:
getDocType in interface PageCtrl

setDocType

public void setDocType(java.lang.String docType)
Description copied from interface: PageCtrl
Sets the doc type (<!DOCTYPE>).

Default: null (i.e., the device default)

Specified by:
setDocType in interface PageCtrl

getFirstLine

public java.lang.String getFirstLine()
Description copied from interface: PageCtrl
Returns the first line to be generated to the output, or null if nothing to generate.

For XML devices, it is usually the xml processing instruction:
<?xml version="1.0" encoding="UTF-8"?>

Specified by:
getFirstLine in interface PageCtrl

setFirstLine

public void setFirstLine(java.lang.String firstLine)
Description copied from interface: PageCtrl
Sets the first line to be generated to the output.

Default: null (i.e., nothing generated)

Specified by:
setFirstLine in interface PageCtrl

getCacheable

public java.lang.Boolean getCacheable()
Description copied from interface: PageCtrl
Returns if the client can cache the rendered result, or null to use the device default.

Specified by:
getCacheable in interface PageCtrl

setCacheable

public void setCacheable(java.lang.Boolean cacheable)
Description copied from interface: PageCtrl
Sets if the client can cache the rendered result.

Default: null (use the device default).

Specified by:
setCacheable in interface PageCtrl

getAutomaticTimeout

public java.lang.Boolean getAutomaticTimeout()
Description copied from interface: PageCtrl
Returns whether to automatically redirect to the timeout URI.

Specified by:
getAutomaticTimeout in interface PageCtrl
See Also:
PageCtrl.setAutomaticTimeout(java.lang.Boolean)

setAutomaticTimeout

public void setAutomaticTimeout(java.lang.Boolean autoTimeout)
Description copied from interface: PageCtrl
Sets whether to automatically redirect to the timeout URI.

Default: null (use the device default).

If it is set to false, it means this page is redirected to the timeout URI when the use takes some action after timeout. In other words, nothing happens if the user does nothing. If it is set to true, it is redirected as soon as timeout, no matter the user takes any action.

Refer to Configuration.setAutomaticTimeout(java.lang.String, boolean) for how to configure the device default (default: false).

Specified by:
setAutomaticTimeout in interface PageCtrl

getDesktop

public final Desktop getDesktop()
Description copied from interface: Page
Returns the desktop that this page belongs to.

Note: it returns null when Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map) is called.

Specified by:
getDesktop in interface Page

redraw

public void redraw(java.io.Writer out)
            throws java.io.IOException
Description copied from interface: PageCtrl
Redraws the whole page into the specified output.

You could use Attributes.PAGE_REDRAW_CONTROL and/or Attributes.PAGE_RENDERER to control how to render manually.

Specified by:
redraw in interface PageCtrl
Throws:
java.io.IOException

getNamespace

public final Namespace getNamespace()
Deprecated. As of release 5.0.0, the concept of namespace is deprecated and replaced with the attributes of a scope (such as a page and a component).

Specified by:
getNamespace in interface Page
See Also:
Page.interpret(java.lang.String, java.lang.String, org.zkoss.zk.scripting.Namespace)

interpret

public void interpret(java.lang.String zslang,
                      java.lang.String script,
                      Scope scope)
Description copied from interface: Page
Interprets a script in the sepcified scripting language in the context of the specified scope.

Specified by:
interpret in interface Page
Parameters:
zslang - the scripting language. If null, Page.getZScriptLanguage() is assumed.
scope - the scope used as the context. Since a component is a scope, you can pass a component as the context. By context we mean the attribute of the scope, its space owner, spacer owner's space owner, page and desktop will be searched. If null, this page is assumed.

interpret

public void interpret(java.lang.String zslang,
                      java.lang.String script,
                      Namespace ns)
Deprecated. As of release 5.0.0, replaced with interpret(String,String,Scope).

Specified by:
interpret in interface Page
Parameters:
zslang - the scripting language. If null, Page.getZScriptLanguage() is assumed.
ns - the namspace. If null, the current namespace is assumed. The current namespace is the event target's namespace (Event.getTarget()), if the thread is processing an event. Otherwise, the current namespace is this page's namespace

getInterpreter

public Interpreter getInterpreter(java.lang.String zslang)
Description copied from interface: Page
Returns the interpreter of the specified scripting language.

The interpreter will be loaded and initialized, if it is not loaded yet.

Specified by:
getInterpreter in interface Page
Parameters:
zslang - the scripting language. If null, Page.getZScriptLanguage() is assumed.

getLoadedInterpreters

public java.util.Collection getLoadedInterpreters()
Description copied from interface: Page
Returns all loaded interpreters.

Specified by:
getLoadedInterpreters in interface Page

getZScriptLanguage

public java.lang.String getZScriptLanguage()
Description copied from interface: Page
Returns the default scripting language which is assumed when a zscript element doesn't specify any language.

Specified by:
getZScriptLanguage in interface Page
Returns:
the default scripting language, say, Java. Never null.

setZScriptLanguage

public void setZScriptLanguage(java.lang.String zslang)
                        throws InterpreterNotFoundException
Description copied from interface: Page
Sets the defafult scripting language which will be assumed if a zscript element doesn't specify any language.

Specified by:
setZScriptLanguage in interface Page
Throws:
InterpreterNotFoundException - if no such language

addDeferredZScript

public void addDeferredZScript(Component parent,
                               ZScript zscript)
Description copied from interface: PageCtrl
Adds a deferred zscript.

Specified by:
addDeferredZScript in interface PageCtrl
Parameters:
parent - the component that is the parent of zscript (in the ZUML page), or null if it belongs to the page.
zscript - the zscript that shall be evaluated as late as when the interpreter of the same language is being loaded.

isListenerAvailable

public boolean isListenerAvailable(java.lang.String evtnm)
Description copied from interface: Page
Returns whether the event listener is available.

Specified by:
isListenerAvailable in interface Page

getListenerIterator

public java.util.Iterator getListenerIterator(java.lang.String evtnm)
Description copied from interface: Page
Returns an iterator for iterating listener for the specified event.

Specified by:
getListenerIterator in interface Page

getOwner

public final Component getOwner()
Description copied from interface: PageCtrl
Returns the owner of this page, or null if it is not owned by any component. A page is included by a component. We say it is owned by the component.

Specified by:
getOwner in interface PageCtrl

setOwner

public final void setOwner(Component comp)
Description copied from interface: PageCtrl
Sets the owner of this page.

Used only internally.

Specified by:
setOwner in interface PageCtrl

getDefaultParent

public Component getDefaultParent()
Deprecated. As of release 5.0.0, the default parent is no longe meaningful.

Specified by:
getDefaultParent in interface PageCtrl

setDefaultParent

public void setDefaultParent(Component comp)
Deprecated. As of release 5.0.0, the default parent is no longe meaningful.

Specified by:
setDefaultParent in interface PageCtrl

sessionWillPassivate

public void sessionWillPassivate(Desktop desktop)
Description copied from interface: PageCtrl
Notification that the session, which owns this page, is about to be passivated (aka., serialized).

Specified by:
sessionWillPassivate in interface PageCtrl

sessionDidActivate

public void sessionDidActivate(Desktop desktop)
Description copied from interface: PageCtrl
Notification that the session, which owns this page, has just been activated (aka., deserialized).

Specified by:
sessionDidActivate in interface PageCtrl

getLanguageDefinition

public LanguageDefinition getLanguageDefinition()
Description copied from interface: Page
Returns the language definition that this page belongs to (never null).

Specified by:
getLanguageDefinition in interface Page

getComponentDefinitionMap

public ComponentDefinitionMap getComponentDefinitionMap()
Description copied from interface: Page
Returns the map of component definitions (never null).

Note: the map is shared among all instance of the same page definition. Any component definition added (by ComponentDefinitionMap.add(org.zkoss.zk.ui.metainfo.ComponentDefinition)) are visible to all other instances of the same page definition. Thus, it is NOT a good idea to change its content.

Specified by:
getComponentDefinitionMap in interface Page

getComponentDefinition

public ComponentDefinition getComponentDefinition(java.lang.String name,
                                                  boolean recurse)
Description copied from interface: Page
Returns the component definition of the specified name, or null if not found.

Note: unlike LanguageDefinition.getComponentDefinition(java.lang.String), this method doesn't throw ComponentNotFoundException if not found. It just returns null.

Specified by:
getComponentDefinition in interface Page
recurse - whether to look up the component from Page.getLanguageDefinition()

getComponentDefinition

public ComponentDefinition getComponentDefinition(java.lang.Class cls,
                                                  boolean recurse)
Description copied from interface: Page
Returns the component definition of the specified class, or null if not found.

Note: unlike LanguageDefinition.getComponentDefinition(java.lang.String), this method doesn't throw ComponentNotFoundException if not found. It just returns null.

Specified by:
getComponentDefinition in interface Page
recurse - whether to look up the component from Page.getLanguageDefinition()

getExpressionFactoryClass

public java.lang.Class getExpressionFactoryClass()
Description copied from interface: Page
Returns the implementation of the expression factory that is used by this page, or null if Configuration.getExpressionFactoryClass() is used.

Default: null.

Specified by:
getExpressionFactoryClass in interface Page
See Also:
Page.setExpressionFactoryClass(java.lang.Class)

setExpressionFactoryClass

public void setExpressionFactoryClass(java.lang.Class expfcls)
Description copied from interface: Page
Sets the implementation of the expression factory that is used by this page.

Specified by:
setExpressionFactoryClass in interface Page
Parameters:
expfcls - the class that implements ExpressionFactory, If null, Configuration.getExpressionFactoryClass() is used.
See Also:
Page.getExpressionFactoryClass()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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