| org.zkoss.zk.ui.Page
All known Subclasses: org.zkoss.zk.ui.impl.PageImpl,
Page | public interface Page extends IdSpace(Code) | | A page. A desktop consists of a set of pages.
When a ZK request is asking to render a new page, a new page is
created and components that are created duing this request all belong to
this page.
If a ZK requst is asking an update, it must have at lease one UUID of
a component (
Component.getUuid .
From this UUID, we know which page it belongs and activate it
to process the update.
By activation, the system guarantees no concurrent access to pages
and components (so you don't need use synchronized for them).
Desktop
In portal and some environments, a client request (e.g., ServletRequest)
might consists of several ZK requests (
org.zkoss.zk.au.AuRequest ).
While each ZK request might ask to create an independent page,
all these pages are grouped as a desktop, such that they are activated
and removed at the same time.
Moreover, pages in the same desktop could communicate to eath other
(see Inter-page communication).
A session,
Session , might have multiple desktops of pages,
Page , while a page belongs to exactly one session.
A page,
Page , might have many components,
Component , while
a component belongs to exactly one page.
All components of the same desktop of pages are removed at the same time
if a page become 'obsolete'.
During each execution (${link Execution}), exactly one desktop of
pages are locked (aka., activated). Though an execution serves
a client request (e.g., ServletRequest), a client request might consist
of multiple ZK request (
org.zkoss.zk.au.AuRequest ).
Each ZK request might target to a different page (of the same desktop).
Inter-page Communication
To do inter-page communication, you could do:
- Invoke methods of components from another page directly.
- Use
Execution.postEvent to post events to components from
another page.
They are the same as handling components from the same page.
However, invoking method directly for components from another page has
one restriction:
It cannot create component.
author: tomyeh |
Method Summary | |
public boolean | addEventListener(String evtnm, EventListener listener) Adds an event listener to specified event for all components in
this page. | public void | addFunctionMapper(FunctionMapper mapper) Adds the function mapper in addition to the current one. | public boolean | addVariableResolver(VariableResolver resolver) Adds a name resolver that will be used to resolve a variable
by
Page.getVariable . | public boolean | containsVariable(String name) Returns whether the specified variable is defined. | public Object | getAttribute(String name, int scope) Returns the value of the specified custom attribute in the specified scope. | public Object | getAttribute(String name) Returns the value of the specified attribute associated with this page. | public Map | getAttributes(int scope) Returns all custom attributes of the specified scope. | public Map | getAttributes() Returns all custom attributes associated with this page. | public ComponentDefinition | getComponentDefinition(String name, boolean recur) Returns the component definition of the specified name, or null
if not found. | public ComponentDefinition | getComponentDefinition(Class cls, boolean recur) Returns the component definition of the specified class, or null
if not found. | public ComponentDefinitionMap | getComponentDefinitionMap() Returns the map of component definitions (never null). | public Desktop | getDesktop() Returns the desktop that this page belongs to. | public Object | getELVariable(String name) Returns a variable that is visible to XEL expressions. | public FunctionMapper | getFunctionMapper() Returns the function mapper for resolving XEL functions, or null if
not available. | public String | getId() Returns ID which is unique in the request (never null). | public Interpreter | getInterpreter(String zslang) Returns the interpreter of the specified scripting language.
The interpreter will be loaded and initialized,
if it is not loaded yet.
Parameters: zslang - the scripting language. | public LanguageDefinition | getLanguageDefinition() Returns the language definition that this page belongs to (never null). | public Iterator | getListenerIterator(String evtnm) Returns an iterator for iterating listener for the specified event. | public Collection | getLoadedInterpreters() Returns all loaded interpreters. | public Namespace | getNamespace() Returns the namespace used to store variables belonging to
the ID space of this page. | public String | getRequestPath() 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. | public Collection | getRoots() Returns a readonly list of the root components. | public String | getStyle() Returns the CSS style of this page, or empty if not specified. | public String | getTitle() Returns the title of the desktop this page belongs to
(and evaluate it if it contains an expression). | public String | getUuid() Returns UUID (universal unique ID) which is unquie in the whole
session. | public Object | getVariable(String name) Returns the value of a variable defined in the namespace (
Page.getNamespace ). | public Object | getXelVariable(String name) Returns a variable that is visible to XEL expressions. | public Class | getZScriptClass(String clsnm) Returns the class of the specified name by searching
the thread class loader and the classes defined in the
loaded interpreters. | public Function | getZScriptFunction(String name, Class[] argTypes) Returns the variable of the specified name by searching
the loaded interpreters. | public Function | getZScriptFunction(Namespace ns, String name, Class[] argTypes) Returns the variable of the specified name by searching
the logical scope of the specified namespace for all
the loaded interpreters.
It is similar to
Page.getZScriptVariable(String) , except
it uses the specified namespace as a reference to identify the
correct scope for searching the variable.
If the interpreter does NOT support hierachical scopes,
this method is the same as
Page.getZScriptVariable(String) .
Parameters: ns - the namespace used as a reference to identify thecorrect 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. | public Function | getZScriptFunction(Component comp, String name, Class[] argTypes) Returns the variable of the specified name by searching
the logical scope of the namespace of the specified component
for all the loaded interpreters. | public String | getZScriptLanguage() Returns the default scripting language which is assumed when
a zscript element doesn't specify any language.
the default scripting language, say, Java. | public org.zkoss.zk.scripting.Method | getZScriptMethod(String name, Class[] argTypes) | public org.zkoss.zk.scripting.Method | getZScriptMethod(Namespace ns, String name, Class[] argTypes) | public Object | getZScriptVariable(String name) Returns the value of the variable of the specified name by searching
the loaded interpreters, if any. | public Object | getZScriptVariable(Namespace ns, String name) Returns the value of the variable of the specified name by searching
the logical scope of the specified namespace for all
the loaded interpreters, if any. | public Object | getZScriptVariable(Component comp, String name) Returns the value of the variable of the specified name by searching
the logical scope of the namespace of the specified component
for all the loaded interpreters, if any. | public void | interpret(String zslang, String script, Namespace ns) Interpret a script of the specified scripting language against
the specified namespace.
Parameters: zslang - the scripting language. | public void | invalidate() Invalidates this page to cause all components to redraw. | public boolean | isListenerAvailable(String evtnm) Returns whether the event listener is available. | public Object | removeAttribute(String name, int scope) Removes the specified custom attribute in the specified scope. | public Object | removeAttribute(String name) Removes the specified attribute custom associated with the page. | public void | removeComponents() Removes all components in this page. | public boolean | removeEventListener(String evtnm, EventListener listener) Removes an event listener. | public boolean | removeVariableResolver(VariableResolver resolver) Removes a name resolve that was added by
Page.addVariableResolver . | public Class | resolveClass(String clsnm) Resolves the class of the specified name. | public Object | setAttribute(String name, Object value, int scope) Sets the value of the specified custom attribute in the specified scope. | public Object | setAttribute(String name, Object value) Sets the value of the specified custom attribute associated with this page.
Note: The attribute is removed (by
Page.removeAttribute if value is null, while
Page.setVariable considers null as a legal value.
Parameters: value - the value. | public void | setId(String id) Sets the identifier of this page. | public void | setStyle(String style) Sets the CSS style of this page. | public void | setTitle(String title) Sets the title of the desktop this page belongs to
(it might contain an expression). | public void | setVariable(String name, Object val) Sets a variable to the namespace (
Page.getNamespace ). | public void | setZScriptLanguage(String zslang) Sets the defafult scripting language which will be assumed
if a zscript element doesn't specify any language. | public void | unsetVariable(String name) Unsets a variable from the namespace (
Page.getNamespace ). |
APPLICATION_SCOPE | final public static int APPLICATION_SCOPE(Code) | | Used with
Page.getAttribute and relevants to denote
custom attributes shared by the whole application.
It is also known as the application attributes.
It is the same as
WebApp.getAttributes .
|
DESKTOP_SCOPE | final public static int DESKTOP_SCOPE(Code) | | Used with
Page.getAttribute and relevants to denote
custom attributes shared by the same desktop.
It is also known as the desktop attributes.
It is the same as
Desktop.getAttributes .
|
PAGE_SCOPE | final public static int PAGE_SCOPE(Code) | | Used with
Page.getAttribute and relevants to denote
custom attributes shared by the same page.
It is also known as the page attributes.
It is the same as
Page.getAttributes .
|
REQUEST_SCOPE | final public static int REQUEST_SCOPE(Code) | | Used with
Page.getAttribute and relevants to denote
custom attributes shared by the same request.
It is also known as the request attributes.
It is the same as
Execution.getAttributes .
|
SESSION_SCOPE | final public static int SESSION_SCOPE(Code) | | Used with
Page.getAttribute and relevants to denote
custom attributes shared by the same session.
It is also known as the session attributes.
It is the same as
Session.getAttributes .
|
addFunctionMapper | public void addFunctionMapper(FunctionMapper mapper)(Code) | | 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
Parameters: mapper - the new function mapper (null to ignore). |
addVariableResolver | public boolean addVariableResolver(VariableResolver resolver)(Code) | | Adds a name resolver that will be used to resolve a variable
by
Page.getVariable .
Note: the variables resolved by the specified resolver are
accessible to both zscript and EL expressions.
wether the resolver is added successfully.Note: if the resolver was added before, it won't be added againand this method returns false. |
containsVariable | public boolean containsVariable(String name)(Code) | | Returns whether the specified variable is defined.
Note: null is a valid value for variable, so this method is used
to know whether a variable is defined.
On the other hand,
Page.setAttribute actually remove
an attribute (by
Page.removeAttribute if value is null.
|
getAttribute | public Object getAttribute(String name)(Code) | | Returns the value of the specified attribute associated with this page.
|
getAttributes | public Map getAttributes()(Code) | | Returns all custom attributes associated with this page.
|
getComponentDefinitionMap | public ComponentDefinitionMap getComponentDefinitionMap()(Code) | | 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 )
are visible to all other instances of the same page definition.
Thus, it is NOT a good idea to change its content.
|
getFunctionMapper | public FunctionMapper getFunctionMapper()(Code) | | Returns the function mapper for resolving XEL functions, or null if
not available.
since: 3.0.0 |
getLanguageDefinition | public LanguageDefinition getLanguageDefinition()(Code) | | Returns the language definition that this page belongs to (never null).
|
getListenerIterator | public Iterator getListenerIterator(String evtnm)(Code) | | Returns an iterator for iterating listener for the specified event.
|
getLoadedInterpreters | public Collection getLoadedInterpreters()(Code) | | Returns all loaded interpreters.
|
getNamespace | public Namespace getNamespace()(Code) | | Returns the namespace used to store variables belonging to
the ID space of this page.
See Also: Page.interpret |
getRequestPath | public String getRequestPath()(Code) | | 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.
See Also: Execution.getContextPath See Also: Desktop.getRequestPath |
getRoots | public Collection getRoots()(Code) | | Returns a readonly list of the root components.
|
getStyle | public String getStyle()(Code) | | Returns the CSS style of this page, or empty if not specified.
|
getTitle | public String getTitle()(Code) | | Returns the title of the desktop this page belongs to
(and evaluate it if it contains an expression).
Default: "".
|
getUuid | public String getUuid()(Code) | | 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.
|
getXelVariable | public Object getXelVariable(String name)(Code) | | Returns a variable that is visible to XEL expressions.
This method is mainly used to access special variable, such as
request parameters (if this page is requested by HTTP).
Note: components that are specified with an ID are already accessible
by
Page.getVariable .
since: 3.0.0 |
getZScriptClass | public Class getZScriptClass(String clsnm)(Code) | | 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 .
the class, or null if not found See Also: Page.getLoadedInterpreters |
getZScriptFunction | public Function getZScriptFunction(Namespace ns, String name, Class[] argTypes)(Code) | | Returns the variable of the specified name by searching
the logical scope of the specified namespace for all
the loaded interpreters.
It is similar to
Page.getZScriptVariable(String) , except
it uses the specified namespace as a reference to identify the
correct scope for searching the variable.
If the interpreter does NOT support hierachical scopes,
this method is the same as
Page.getZScriptVariable(String) .
Parameters: ns - the namespace used as a reference to identify thecorrect 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. the method, or null if not found See Also: Page.getLoadedInterpreters since: 2.4.1 |
getZScriptFunction | public Function getZScriptFunction(Component comp, String name, Class[] argTypes)(Code) | | Returns the variable of the specified name by searching
the logical scope of the namespace of the specified component
for all the loaded interpreters.
It is a shortcut: getZScriptFunction(comp.getNamespace(), name, argTypes);
since: 3.0.0 |
getZScriptLanguage | public String getZScriptLanguage()(Code) | | Returns the default scripting language which is assumed when
a zscript element doesn't specify any language.
the default scripting language, say, Java. Never null. |
getZScriptVariable | public Object getZScriptVariable(Namespace ns, String name)(Code) | | Returns the value of the variable of the specified name by searching
the logical scope of the specified namespace for all
the loaded interpreters, if any.
It is similar to
Page.getZScriptVariable(String) , except
it uses the specified namespace as a reference to identify the
correct scope for searching the variable.
If the interpreter does NOT support hierachical scopes,
this method is the same as
Page.getZScriptVariable(String) .
Parameters: ns - the namespace used as a reference to identify thecorrect 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. |
getZScriptVariable | public Object getZScriptVariable(Component comp, String name)(Code) | | Returns the value of the variable of the specified name by searching
the logical scope of the namespace of the specified component
for all the loaded interpreters, if any.
It is a shortcut: getZScriptVariable(comp.getNamespace(), name);
since: 3.0.0 |
interpret | public void interpret(String zslang, String script, Namespace ns)(Code) | | Interpret a script of the specified scripting language against
the specified namespace.
Parameters: zslang - the scripting language. If null, Page.getZScriptLanguageis assumed. Parameters: ns - the namspace. If null, the current namespace is assumed.The current namespace is the event target's namespace(org.zkoss.zk.ui.event.Event.getTarget),if the thread is processing an event.Otherwise, the current namespace is this page's namespace |
invalidate | public void invalidate()(Code) | | Invalidates this page to cause all components to redraw.
|
isListenerAvailable | public boolean isListenerAvailable(String evtnm)(Code) | | Returns whether the event listener is available.
|
removeAttribute | public Object removeAttribute(String name)(Code) | | Removes the specified attribute custom associated with the page.
|
removeEventListener | public boolean removeEventListener(String evtnm, EventListener listener)(Code) | | Removes an event listener.
whether the listener is removed; false if it was never added. |
setAttribute | public Object setAttribute(String name, Object value)(Code) | | Sets the value of the specified custom attribute associated with this page.
Note: The attribute is removed (by
Page.removeAttribute if value is null, while
Page.setVariable considers null as a legal value.
Parameters: value - the value. If null, the attribute is removed. |
setStyle | public void setStyle(String style)(Code) | | Sets the CSS style of this page.
Note: Unlike
Page.setTitle , you can change the style only in
the lifecycle of the loading page.
|
setTitle | public void setTitle(String title)(Code) | | Sets the title of the desktop this page belongs to
(it might contain an expression).
|
|
|