Class PageImpl
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractPage
-
- org.zkoss.zk.ui.impl.PageImpl
-
- All Implemented Interfaces:
java.io.Serializable,org.zkoss.lang.ClassResolver,Scope,IdSpace,Page,PageCtrl
- Direct Known Subclasses:
VolatilePage
public class PageImpl extends AbstractPage implements java.io.Serializable
An implementation ofPageandPageCtrl. Refer to them for more details.Note: though
PageImplis serializable, it is designed to work with Web container to enable the serialization of sessions. It is not suggested to serialize and deserialize 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
-
-
Constructor Summary
Constructors Constructor Description 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(Page ref)Constructs a page with another page as instancePageImpl(Richlet richlet, java.lang.String path)Constructs a page by specifying a richlet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAfterHeadTags(java.lang.String tags)Adds the tags that will be generated inside the head element and after ZK's default tags.voidaddBeforeHeadTags(java.lang.String tags)Adds the tags that will be generated inside the head element and before ZK's default tags.booleanaddClassResolver(org.zkoss.lang.ClassResolver resolver)Adds a class resolver to this page.voidaddDeferredZScript(Component parent, ZScript zscript)Adds a deferred zscript.booleanaddEventListener(java.lang.String evtnm, EventListener<? extends Event> listener)Adds an event listener to specified event for all components in this page.booleanaddFunctionMapper(org.zkoss.xel.FunctionMapper mapper)Adds the function mapper in addition to the current one.booleanaddScopeListener(ScopeListener listener)Adds a listener to listen whether this scope is changed.voidaddTemplate(java.lang.String name, Template template)Adds page scope templatebooleanaddVariableResolver(org.zkoss.xel.VariableResolver resolver)Adds a variable resolver that will be used to resolve a variable byPage.getXelVariable(java.lang.String).voiddestroy()Called when this page is about to be destroyed.java.lang.StringgetAfterHeadTags()Returns the tags that shall be generated inside the head element and after ZK's default tags (never null).java.lang.ObjectgetAttribute(java.lang.String name)Returns the value of the specified attribute associated with this page.java.lang.ObjectgetAttribute(java.lang.String name, boolean recurse)Returns the custom attribute associated with this object.java.lang.ObjectgetAttribute(java.lang.String name, int scope)Returns the value of the specified custom attribute in the specified scope.java.lang.ObjectgetAttributeOrFellow(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<java.lang.String,java.lang.Object>getAttributes()Returns all custom attributes associated with this page.java.util.Map<java.lang.String,java.lang.Object>getAttributes(int scope)Returns all custom attributes of the specified scope.java.lang.BooleangetAutomaticTimeout()Returns whether to automatically redirect to the timeout URI.java.lang.StringgetBeforeHeadTags()Returns the tags that shall be generated inside the head element and before ZK's default tags (never null).java.lang.BooleangetCacheable()Returns if the client can cache the rendered result, or null to use the device default.org.zkoss.lang.ClassResolvergetClassResolver()Internal used onlyComponentDefinitiongetComponentDefinition(java.lang.Class<? extends Component> cls, boolean recurse)Returns the component definition of the specified class, or null if not found.ComponentDefinitiongetComponentDefinition(java.lang.String name, boolean recurse)Returns the component definition of the specified name, or null if not found.ComponentDefinitionMapgetComponentDefinitionMap()Returns the map of component definitions (never null).java.lang.StringgetContentType()Returns the content type, or null to use the device default.DesktopgetDesktop()Returns the desktop that this page belongs to.java.lang.StringgetDocType()Returns the doc type (<!java.lang.Iterable<EventListener<? extends Event>>getEventListeners(java.lang.String evtnm)Returns an iterable collection of the event listeners for the given event.java.lang.Class<? extends org.zkoss.xel.ExpressionFactory>getExpressionFactoryClass()Returns the implementation of the expression factory that is used by this page, or null ifConfiguration.getExpressionFactoryClass()is used.java.lang.StringgetFirstLine()Returns the first line to be generated to the output, or null if nothing to generate.org.zkoss.xel.FunctionMappergetFunctionMapper()Returns the function mapper for resolving XEL functions, or null if not available.java.lang.StringgetId()Returns ID which is unique in the request (never null).InterpretergetInterpreter(java.lang.String zslang)Returns the interpreter of the specified scripting language.LanguageDefinitiongetLanguageDefinition()Returns the language definition that this page belongs to (never null).java.util.Collection<Interpreter>getLoadedInterpreters()Returns all loaded interpreters.ComponentgetOwner()Returns the owner of this page, or null if it is not owned by any component.java.lang.StringgetRequestPath()Returns the request path of this page, or "" if not available.java.util.Collection<java.lang.Object[]>getResponseHeaders()Returns a readonly collection of response headers (never null).java.lang.StringgetRootAttributes()Returns the attributes of the root element declared in this page (never null).java.lang.StringgetStyle()Returns the CSS style of this page, or empty if not specified.TemplategetTemplate(java.lang.String name)Gets page scope template by namejava.lang.StringgetTitle()Returns the title of the desktop this page belongs to (and evaluate it if it contains an expression).java.lang.StringgetUuid()Returns UUID (universal unique ID) which is unique in the whole session.java.lang.StringgetViewport()Return the meta viewport of this page, or "auto" if not specified.java.lang.StringgetWidgetClass()Returns the widget class of this page, or null to use the device default.java.lang.ObjectgetXelVariable(java.lang.String name)Returns a variable that is visible to XEL expressions.java.lang.ObjectgetXelVariable(org.zkoss.xel.XelContext ctx, java.lang.Object base, java.lang.Object name, boolean ignoreExec)Returns a variable that is visible to XEL expressions.java.lang.Class<?>getZScriptClass(java.lang.String clsnm)Returns the class of the specified name by searching the classes defined in the loaded interpreters (Page.getLoadedInterpreters()).org.zkoss.xel.FunctiongetZScriptFunction(java.lang.String name, java.lang.Class[] argTypes)Returns the function of the specified name by searching the loaded interpreters.org.zkoss.xel.FunctiongetZScriptFunction(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.java.lang.StringgetZScriptLanguage()Returns the default scripting language which is assumed when a zscript element doesn't specify any language.java.lang.ObjectgetZScriptVariable(java.lang.String name)Returns the value of the variable of the specified name by searching the loaded interpreters, if any.java.lang.ObjectgetZScriptVariable(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.booleanhasAttribute(java.lang.String name)Returns if an attribute exists.booleanhasAttribute(java.lang.String name, boolean recurse)Returns if a custom attribute is associated with this object.booleanhasAttribute(java.lang.String name, int scope)Returns if an attribute exists.booleanhasAttributeOrFellow(java.lang.String name, boolean recurse)Returns if a custom attribute is associated with this page, or a fellow of this page.booleanhasFunctionMapper(org.zkoss.xel.FunctionMapper mapper)Returns if the specified function mapper has been registeredbooleanhasVariableResolver(org.zkoss.xel.VariableResolver resolver)Returns if the specified variable resolver has been registeredprotected voidinit()Initialized the page when constructed or deserialized.voidinit(PageConfig config)Initializes this page by assigning the info provided by the specifiedPageConfig, and then adds it to a desktop (by use ofExecution.getDesktop()).voidinterpret(java.lang.String zslang, java.lang.String script, Scope scope)Interprets a script in the specified scripting language in the context of the specified scope.voidinvalidate()Invalidates this page to cause all components to redraw.booleanisAlive()Returns whether the desktop is still alive.booleanisComplete()Returns if this page is a complete page.booleanisListenerAvailable(java.lang.String evtnm)Returns whether the event listener is available.voidpreInit()Pre-initializes this page.voidredraw(java.io.Writer out)Redraws the whole page into the specified output.java.lang.ObjectremoveAttribute(java.lang.String name)Removes the specified attribute custom associated with the page.java.lang.ObjectremoveAttribute(java.lang.String name, boolean recurse)Removes the custom attribute associated with this scope.java.lang.ObjectremoveAttribute(java.lang.String name, int scope)Removes the specified custom attribute in the specified scope.booleanremoveEventListener(java.lang.String evtnm, EventListener<? extends Event> listener)Removes an event listener.booleanremoveFunctionMapper(org.zkoss.xel.FunctionMapper mapper)Removes a function mapper that was added byPage.addFunctionMapper(org.zkoss.xel.FunctionMapper).booleanremoveScopeListener(ScopeListener listener)Removes a change listener from this scope.voidremoveTemplate(java.lang.String name)Removes page scope templatebooleanremoveVariableResolver(org.zkoss.xel.VariableResolver resolver)Removes a variable resolver that was added byPage.addVariableResolver(org.zkoss.xel.VariableResolver).java.lang.Class<?>resolveClass(java.lang.String clsnm)Resolves the class of the specified name.voidsessionDidActivate(Desktop desktop)Notification that the session, which owns this page, has just been activated (a.k.a., deserialized).voidsessionWillPassivate(Desktop desktop)Notification that the session, which owns this page, is about to be passivated (a.k.a., serialized).java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value)Sets the value of the specified custom attribute associated with this page.java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value, boolean recurse)Sets the custom attribute associated with this scope, or the parent scope.java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value, int scope)Sets the value of the specified custom attribute in the specified scope.voidsetAutomaticTimeout(java.lang.Boolean autoTimeout)Sets whether to automatically redirect to the timeout URI.voidsetCacheable(java.lang.Boolean cacheable)Sets if the client can cache the rendered result.voidsetComplete(boolean complete)Sets if the page is a complete page.voidsetContentType(java.lang.String contentType)Sets the content type.voidsetDocType(java.lang.String docType)Sets the doc type (<!voidsetExpressionFactoryClass(java.lang.Class<? extends org.zkoss.xel.ExpressionFactory> expfcls)Sets the implementation of the expression factory that is used by this page.voidsetFirstLine(java.lang.String firstLine)Sets the first line to be generated to the output.voidsetId(java.lang.String id)Sets the identifier of this page.voidsetOwner(Component comp)Sets the owner of this page.voidsetRootAttributes(java.lang.String rootAttrs)Set the attributes of the root element declared in this pagevoidsetStyle(java.lang.String style)Sets the CSS style of this page.voidsetTitle(java.lang.String title)Sets the title of the desktop this page belongs to (it might contain an expression).voidsetViewport(java.lang.String viewport)Sets the viewport of this page.voidsetWidgetClass(java.lang.String wgtcls)Sets the widget class of this page.voidsetZScriptLanguage(java.lang.String zslang)Sets the default scripting language which will be assumed if a zscript element doesn't specify any language.java.lang.StringtoString()-
Methods inherited from class org.zkoss.zk.ui.AbstractPage
getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstRoot, getLastRoot, getRoots, hasFellow, hasFellow, removeComponents
-
-
-
-
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? Constructor could be called before execution is activated, butinit()must be called in an execution.Also note that
getId()andgetTitle()are not ready untilinit()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(Page ref)
Constructs a page with another page as instance- Since:
- 6.0.0
-
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()andgetTitle()are not ready untilinit()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 constructed or deserialized.
-
init
public void init(PageConfig config)
Description copied from interface:PageCtrlInitializes this page by assigning the info provided by the specifiedPageConfig, and then adds it to a desktop (by use ofExecution.getDesktop()).Note: this method is called after
PageCtrl.preInit()andInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>).This method shall be called only after the current execution is activated.
-
getFunctionMapper
public final org.zkoss.xel.FunctionMapper getFunctionMapper()
Description copied from interface:PageReturns the function mapper for resolving XEL functions, or null if not available. The function mapper represents all function mappers being added.- Specified by:
getFunctionMapperin interfacePage
-
addFunctionMapper
public boolean addFunctionMapper(org.zkoss.xel.FunctionMapper mapper)
Description copied from interface:PageAdds 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:
addFunctionMapperin interfacePage- Parameters:
mapper- the new function mapper (null to ignore).
-
removeFunctionMapper
public boolean removeFunctionMapper(org.zkoss.xel.FunctionMapper mapper)
Description copied from interface:PageRemoves a function mapper that was added byPage.addFunctionMapper(org.zkoss.xel.FunctionMapper).- Specified by:
removeFunctionMapperin interfacePage- Returns:
- false if the mapper is not added before.
-
hasFunctionMapper
public boolean hasFunctionMapper(org.zkoss.xel.FunctionMapper mapper)
Description copied from interface:PageReturns if the specified function mapper has been registered- Specified by:
hasFunctionMapperin interfacePage- See Also:
Page.addFunctionMapper(org.zkoss.xel.FunctionMapper)
-
getRequestPath
public java.lang.String getRequestPath()
Description copied from interface:PageReturns the request path of this page, or "" if not available.It is the same as the servlet path (jakarta.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:
getRequestPathin interfacePage- See Also:
Execution.getContextPath(),Desktop.getRequestPath()
-
getId
public final java.lang.String getId()
Description copied from interface:PageReturns ID which is unique in the request (never null).Note: it returns null when
Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)is called.
-
getUuid
public final java.lang.String getUuid()
Description copied from interface:PageReturns UUID (universal unique ID) which is unique 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.
-
setId
public void setId(java.lang.String id)
Description copied from interface:PageSets 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<java.lang.String, java.lang.Object>)orExecutionInit.init(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Execution). Once the page is initialized (byPageCtrl.init(org.zkoss.zk.ui.sys.PageConfig)), calling this method will cause an exception.
-
getTitle
public java.lang.String getTitle()
Description copied from interface:PageReturns the title of the desktop this page belongs to (and evaluate it if it contains an expression).Default: "".
-
setTitle
public void setTitle(java.lang.String title)
Description copied from interface:PageSets the title of the desktop this page belongs to (it might contain an expression).
-
getStyle
public java.lang.String getStyle()
Description copied from interface:PageReturns the CSS style of this page, or empty if not specified.
-
setStyle
public void setStyle(java.lang.String style)
Description copied from interface:PageSets 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.
-
getViewport
public java.lang.String getViewport()
Description copied from interface:PageReturn the meta viewport of this page, or "auto" if not specified.Default: "auto".
- Specified by:
getViewportin interfacePage
-
setViewport
public void setViewport(java.lang.String viewport)
Description copied from interface:PageSets the viewport of this page.- Specified by:
setViewportin interfacePage
-
getAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAttributes(int scope)
Description copied from interface:PageReturns all custom attributes of the specified scope. You could reference them directly, or by use of 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 desktops as this one's.- Specified by:
getAttributesin interfacePage- Parameters:
scope- one ofPage.APPLICATION_SCOPE,Page.SESSION_SCOPE,Page.PAGE_SCOPE,Page.REQUEST_SCOPEorPage.DESKTOP_SCOPE.
-
getAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Description copied from interface:PageReturns all custom attributes associated with this page.- Specified by:
getAttributesin interfacePage- Specified by:
getAttributesin interfaceScope
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name, int scope)Description copied from interface:PageReturns 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 desktops as this one's.- Specified by:
getAttributein interfacePagescope- one ofPage.APPLICATION_SCOPE,Page.SESSION_SCOPE,Page.PAGE_SCOPE,Page.REQUEST_SCOPEorPage.DESKTOP_SCOPE.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface:PageReturns the value of the specified attribute associated with this page.- Specified by:
getAttributein interfacePage- Specified by:
getAttributein interfaceScope
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name, boolean recurse)Description copied from interface:ScopeReturns the custom attribute associated with this object.- Specified by:
getAttributein interfaceScoperecurse- 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, int scope)Description copied from interface:PageReturns if an attribute exists.Notice that
nullis a valid value, so you need this method to really know if an attribute is defined.- Specified by:
hasAttributein interfacePage
-
hasAttribute
public boolean hasAttribute(java.lang.String name)
Description copied from interface:PageReturns if an attribute exists.Notice that
nullis a valid value, so you need this method to really know if an attribute is defined.- Specified by:
hasAttributein interfacePage- Specified by:
hasAttributein interfaceScope
-
hasAttribute
public boolean hasAttribute(java.lang.String name, boolean recurse)Description copied from interface:ScopeReturns if a custom attribute is associated with this object.Notice that
nullis a valid value, so you can tell if an attribute is associated by examining the return value ofScope.getAttribute(java.lang.String).- Specified by:
hasAttributein interfaceScoperecurse- 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, int scope)Description copied from interface:PageSets 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 desktops as this one's.- Specified by:
setAttributein interfacePagescope- one ofPage.APPLICATION_SCOPE,Page.SESSION_SCOPE,Page.PAGE_SCOPE,Page.REQUEST_SCOPEorPage.DESKTOP_SCOPE.
-
setAttribute
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)Description copied from interface:PageSets the value of the specified custom attribute associated with this page.- Specified by:
setAttributein interfacePage- Specified by:
setAttributein interfaceScopevalue- the value.- Returns:
- the previous value associated with the attribute, if any
-
setAttribute
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value, boolean recurse)Description copied from interface:ScopeSets the custom attribute associated with this scope, or the parent scope.- Specified by:
setAttributein interfaceScoperecurse- 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 asScope.setAttribute(String,Object).
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name, int scope)Description copied from interface:PageRemoves 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 desktops as this one's.- Specified by:
removeAttributein interfacePagescope- one ofPage.APPLICATION_SCOPE,Page.SESSION_SCOPE,Page.PAGE_SCOPE,Page.REQUEST_SCOPEorPage.DESKTOP_SCOPE.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
Description copied from interface:PageRemoves the specified attribute custom associated with the page.- Specified by:
removeAttributein interfacePage- Specified by:
removeAttributein interfaceScope- Returns:
- the previous value associated with the attribute, if any,
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name, boolean recurse)Description copied from interface:ScopeRemoves the custom attribute associated with this scope.- Specified by:
removeAttributein interfaceScoperecurse- 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 asScope.removeAttribute(String).
-
getAttributeOrFellow
public java.lang.Object getAttributeOrFellow(java.lang.String name, boolean recurse)Description copied from interface:PageReturns 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 invokePage.getXelVariable(XelContext,Object,Object,boolean)orPage.getXelVariable(String)manually.- Specified by:
getAttributeOrFellowin interfacePagerecurse- 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:PageReturns 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 invokePage.getXelVariable(XelContext,Object,Object,boolean)orPage.getXelVariable(String)manually.- Specified by:
hasAttributeOrFellowin interfacePagerecurse- whether to look up the desktop/session for the existence of the attribute.
-
addScopeListener
public boolean addScopeListener(ScopeListener listener)
Description copied from interface:ScopeAdds 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:
addScopeListenerin interfaceScope- Returns:
- weather 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:ScopeRemoves a change listener from this scope.- Specified by:
removeScopeListenerin interfaceScope- Returns:
- false if listener is not added before.
-
invalidate
public void invalidate()
Description copied from interface:PageInvalidates this page to cause all components to redraw.- Specified by:
invalidatein interfacePage
-
addClassResolver
public boolean addClassResolver(org.zkoss.lang.ClassResolver resolver)
Description copied from interface:PageAdds a class resolver to this page.- Specified by:
addClassResolverin interfacePage- Parameters:
resolver- the class resolver to be added. Currently it supports onlyImportedClassResolver.- See Also:
Page.resolveClass(java.lang.String)
-
resolveClass
public java.lang.Class<?> resolveClass(java.lang.String clsnm) throws java.lang.ClassNotFoundExceptionDescription copied from interface:PageResolves the class of the specified name. It first looks atClassResolver(registered withPage.addClassResolver(org.zkoss.lang.ClassResolver)). If not found, it looks at the current thread's class loader. And then, it looks for classes defined in any loaded interpreters (Page.getLoadedInterpreters()).- Specified by:
resolveClassin interfaceorg.zkoss.lang.ClassResolver- Specified by:
resolveClassin interfacePage- Parameters:
clsnm- the class name. It does not have to be a fully qualified name (i.e., it could have no package name), if the class is imported by use of the import directive (such as <?import class="com.foo.*"?>).- Throws:
java.lang.ClassNotFoundException
-
getClassResolver
public org.zkoss.lang.ClassResolver getClassResolver()
Description copied from interface:PageCtrlInternal used only- Specified by:
getClassResolverin interfacePageCtrl
-
getZScriptClass
public java.lang.Class<?> getZScriptClass(java.lang.String clsnm)
Description copied from interface:PageReturns the class of the specified name by searching the classes defined in the loaded interpreters (Page.getLoadedInterpreters()).Note that: since ZK 6, this method will not search the current thread's class loader. In other words, you'd like to look for a class from a given page, use
Page.resolveClass(java.lang.String)instead.Also notice that it won't throw an exception if not found. Rather, it returns null.
- Specified by:
getZScriptClassin interfacePage- Parameters:
clsnm- the fully qualified class name. UnlikePage.resolveClass(java.lang.String), this method does not support the imported class (byPage.addClassResolver(org.zkoss.lang.ClassResolver)).- Returns:
- the class, or null if not found
- See Also:
Page.resolveClass(java.lang.String),Page.getLoadedInterpreters()
-
getZScriptFunction
public org.zkoss.xel.Function getZScriptFunction(java.lang.String name, java.lang.Class[] argTypes)Description copied from interface:PageReturns the function of the specified name by searching the loaded interpreters.- Specified by:
getZScriptFunctionin interfacePage- Returns:
- the method, or null if not found
- See Also:
Page.getLoadedInterpreters()
-
getZScriptFunction
public org.zkoss.xel.Function getZScriptFunction(Component comp, java.lang.String name, java.lang.Class[] argTypes)
Description copied from interface:PageReturns the function of the specified name by searching the logical scope of the specified component in all the loaded interpreters.- Specified by:
getZScriptFunctionin interfacePage- 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 asPage.getZScriptFunction(String, Class[]).
-
getZScriptVariable
public java.lang.Object getZScriptVariable(java.lang.String name)
Description copied from interface:PageReturns the value of the variable of the specified name by searching the loaded interpreters, if any.- Specified by:
getZScriptVariablein interfacePage- 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:PageReturns 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:
getZScriptVariablein interfacePage- 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.
-
getXelVariable
public java.lang.Object getXelVariable(java.lang.String name)
Description copied from interface:PageReturns a variable that is visible to XEL expressions. It is a shortcut ofgetXelVariable(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:
getXelVariablein interfacePage- See Also:
Page.getXelVariable(XelContext, Object, Object, boolean)
-
getXelVariable
public java.lang.Object getXelVariable(org.zkoss.xel.XelContext ctx, java.lang.Object base, java.lang.Object name, boolean ignoreExec)Description copied from interface:PageReturns a variable that is visible to XEL expressions.Unlike
Page.getXelVariable(String), this method can utilizeVariableResolverXif you'd like to retrieve a property of another object.- Specified by:
getXelVariablein interfacePage- Parameters:
ctx- the XEL contextbase- 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 aspageanddesktopwill be resolved.- See Also:
Page.getXelVariable(String)
-
addVariableResolver
public boolean addVariableResolver(org.zkoss.xel.VariableResolver resolver)
Description copied from interface:PageAdds a variable resolver that will be used to resolve a variable byPage.getXelVariable(java.lang.String).The new added variable resolver has the higher priority.
Note: the variables resolver by the specified resolver are accessible to both zscript and EL expressions.
- Specified by:
addVariableResolverin interfacePage- Returns:
- whether 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(org.zkoss.xel.VariableResolver resolver)
Description copied from interface:PageRemoves a variable resolver that was added byPage.addVariableResolver(org.zkoss.xel.VariableResolver).- Specified by:
removeVariableResolverin interfacePage- Returns:
- false if the resolver is not added before.
-
hasVariableResolver
public boolean hasVariableResolver(org.zkoss.xel.VariableResolver resolver)
Description copied from interface:PageReturns if the specified variable resolver has been registered- Specified by:
hasVariableResolverin interfacePage- See Also:
Page.addVariableResolver(org.zkoss.xel.VariableResolver)
-
addEventListener
public boolean addEventListener(java.lang.String evtnm, EventListener<? extends Event> listener)Description copied from interface:PageAdds an event listener to specified event for all components in this page.Due to performance consideration, unlike
Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>), all event listeners for the page are deferrable, no matterDeferrableis implemented or not.Version Difference
ZK 5.0 and earlier, the second registration is ignored if an event listener has been registered twice. However, since 6.0.0 and later, it won't be ignored. If a listener has been registered multiple times, it will be invoked multiple times.
If you prefer to ignore the second registration, you could specify a library property called "org.zkoss.zk.ui.EventListener.duplicateIgnored" to true.
- Specified by:
addEventListenerin interfacePage- Parameters:
evtnm- what event to listen (never null)- Returns:
- whether the listener is added successfully
- See Also:
Component.addEventListener(int, java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)
-
removeEventListener
public boolean removeEventListener(java.lang.String evtnm, EventListener<? extends Event> listener)Description copied from interface:PageRemoves an event listener.- Specified by:
removeEventListenerin interfacePage- Returns:
- whether the listener is removed; false if it was never added.
-
isComplete
public boolean isComplete()
Description copied from interface:PageReturns 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
includecomponent).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:
isCompletein interfacePage
-
setComplete
public void setComplete(boolean complete)
Description copied from interface:PageSets 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:
setCompletein interfacePage- 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:PageCtrlPre-initializes this page. It initializesPage.getDesktop(), but it doesn't add this page to the desktop yet (which is done byPageCtrl.init(org.zkoss.zk.ui.sys.PageConfig)).Note: it is called before
Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)andPageCtrl.init(org.zkoss.zk.ui.sys.PageConfig). SincePage.getDesktop()is initialized in this method, it is OK to create components inInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>).
-
destroy
public void destroy()
Description copied from interface:PageCtrlCalled when this page is about to be destroyed. It is called by desktop, after removing it from the desktop.- Specified by:
destroyin interfacePageCtrl- Overrides:
destroyin classAbstractPage
-
isAlive
public boolean isAlive()
Description copied from interface:PageReturns whether the desktop is still alive. It returns false once it is destroyed.- Specified by:
isAlivein interfacePage- See Also:
PageCtrl.destroy()
-
getBeforeHeadTags
public java.lang.String getBeforeHeadTags()
Description copied from interface:PageCtrlReturns the tags that shall be generated inside the head element and before ZK's default tags (never null). For example, it might consist of <meta> and <link>.Since it is generated before ZK's default tags (such as CSS and JS), it cannot override ZK's default behaviors.
- Specified by:
getBeforeHeadTagsin interfacePageCtrl- See Also:
PageCtrl.getAfterHeadTags()
-
getAfterHeadTags
public java.lang.String getAfterHeadTags()
Description copied from interface:PageCtrlReturns the tags that shall be generated inside the head element and after ZK's default tags (never null). For example, it might consist of <meta> and <link>.Since it is generated after ZK's default tags (such as CSS and JS), it could override ZK's default behaviors.
- Specified by:
getAfterHeadTagsin interfacePageCtrl- See Also:
PageCtrl.getBeforeHeadTags()
-
addBeforeHeadTags
public void addBeforeHeadTags(java.lang.String tags)
Description copied from interface:PageCtrlAdds the tags that will be generated inside the head element and before ZK's default tags. For example,((PageCtrl)page).addBeforeHeadTags("<meta name=\"robots\" content=\"index,follow\"/>");You could specify the link, meta and script directive to have the similar result.
- Specified by:
addBeforeHeadTagsin interfacePageCtrl
-
addAfterHeadTags
public void addAfterHeadTags(java.lang.String tags)
Description copied from interface:PageCtrlAdds the tags that will be generated inside the head element and after ZK's default tags. For example,((PageCtrl)page).addBeforeHeadTags("<meta name=\"robots\" content=\"index,follow\"/>");You could specify the link, meta and script directive to have the similar result.
- Specified by:
addAfterHeadTagsin interfacePageCtrl
-
getResponseHeaders
public java.util.Collection<java.lang.Object[]> getResponseHeaders()
Description copied from interface:PageCtrlReturns a readonly collection of response headers (never null). The entry is a three-element object array. The first element is the header name. The second element of the array is the value which is an instance ofDateorString(and never null). The third element indicates whether to add (rather than set) theader. It is an instance of Boolean (and never null).- Specified by:
getResponseHeadersin interfacePageCtrl
-
getRootAttributes
public java.lang.String getRootAttributes()
Description copied from interface:PageCtrlReturns 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:
getRootAttributesin interfacePageCtrl
-
setRootAttributes
public void setRootAttributes(java.lang.String rootAttrs)
Description copied from interface:PageCtrlSet the attributes of the root element declared in this pageDefault: "".
- Specified by:
setRootAttributesin interfacePageCtrl
-
getContentType
public java.lang.String getContentType()
Description copied from interface:PageCtrlReturns the content type, or null to use the device default.- Specified by:
getContentTypein interfacePageCtrl
-
setContentType
public void setContentType(java.lang.String contentType)
Description copied from interface:PageCtrlSets the content type.- Specified by:
setContentTypein interfacePageCtrl
-
getWidgetClass
public java.lang.String getWidgetClass()
Description copied from interface:PageCtrlReturns the widget class of this page, or null to use the device default.- Specified by:
getWidgetClassin interfacePageCtrl
-
setWidgetClass
public void setWidgetClass(java.lang.String wgtcls)
Description copied from interface:PageCtrlSets the widget class of this page.- Specified by:
setWidgetClassin interfacePageCtrl- Parameters:
wgtcls- the widget class. The device default is assumed if wgtcls is null or empty.
-
getDocType
public java.lang.String getDocType()
Description copied from interface:PageCtrlReturns the doc type (<!DOCTYPE>), or null to use the device default.- Specified by:
getDocTypein interfacePageCtrl
-
setDocType
public void setDocType(java.lang.String docType)
Description copied from interface:PageCtrlSets the doc type (<!DOCTYPE>).Default: null (i.e., the device default)
- Specified by:
setDocTypein interfacePageCtrl
-
getFirstLine
public java.lang.String getFirstLine()
Description copied from interface:PageCtrlReturns 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:
getFirstLinein interfacePageCtrl
-
setFirstLine
public void setFirstLine(java.lang.String firstLine)
Description copied from interface:PageCtrlSets the first line to be generated to the output.Default: null (i.e., nothing generated)
- Specified by:
setFirstLinein interfacePageCtrl
-
getCacheable
public java.lang.Boolean getCacheable()
Description copied from interface:PageCtrlReturns if the client can cache the rendered result, or null to use the device default.- Specified by:
getCacheablein interfacePageCtrl
-
setCacheable
public void setCacheable(java.lang.Boolean cacheable)
Description copied from interface:PageCtrlSets if the client can cache the rendered result.Default: null (use the device default).
- Specified by:
setCacheablein interfacePageCtrl
-
getAutomaticTimeout
public java.lang.Boolean getAutomaticTimeout()
Description copied from interface:PageCtrlReturns whether to automatically redirect to the timeout URI.- Specified by:
getAutomaticTimeoutin interfacePageCtrl- See Also:
PageCtrl.setAutomaticTimeout(java.lang.Boolean)
-
setAutomaticTimeout
public void setAutomaticTimeout(java.lang.Boolean autoTimeout)
Description copied from interface:PageCtrlSets 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:
setAutomaticTimeoutin interfacePageCtrl
-
getDesktop
public final Desktop getDesktop()
Description copied from interface:PageReturns the desktop that this page belongs to.Note: it returns null when
Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)is called.- Specified by:
getDesktopin interfacePage
-
redraw
public void redraw(java.io.Writer out) throws java.io.IOExceptionDescription copied from interface:PageCtrlRedraws the whole page into the specified output.You could use
Attributes.PAGE_REDRAW_CONTROLand/orAttributes.PAGE_RENDERERto control how to render manually.
-
interpret
public void interpret(java.lang.String zslang, java.lang.String script, Scope scope)Description copied from interface:PageInterprets a script in the specified scripting language in the context of the specified scope.- Specified by:
interpretin interfacePage- 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.
-
getInterpreter
public Interpreter getInterpreter(java.lang.String zslang)
Description copied from interface:PageReturns the interpreter of the specified scripting language.The interpreter will be loaded and initialized, if it is not loaded yet.
- Specified by:
getInterpreterin interfacePage- Parameters:
zslang- the scripting language. If null,Page.getZScriptLanguage()is assumed.
-
getLoadedInterpreters
public java.util.Collection<Interpreter> getLoadedInterpreters()
Description copied from interface:PageReturns all loaded interpreters.- Specified by:
getLoadedInterpretersin interfacePage
-
getZScriptLanguage
public java.lang.String getZScriptLanguage()
Description copied from interface:PageReturns the default scripting language which is assumed when a zscript element doesn't specify any language.- Specified by:
getZScriptLanguagein interfacePage- Returns:
- the default scripting language, say, Java. Never null.
-
setZScriptLanguage
public void setZScriptLanguage(java.lang.String zslang) throws InterpreterNotFoundExceptionDescription copied from interface:PageSets the default scripting language which will be assumed if a zscript element doesn't specify any language.- Specified by:
setZScriptLanguagein interfacePage- Throws:
InterpreterNotFoundException- if no such language
-
addDeferredZScript
public void addDeferredZScript(Component parent, ZScript zscript)
Description copied from interface:PageCtrlAdds a deferred zscript.- Specified by:
addDeferredZScriptin interfacePageCtrl- 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:PageReturns whether the event listener is available.- Specified by:
isListenerAvailablein interfacePage
-
getEventListeners
public java.lang.Iterable<EventListener<? extends Event>> getEventListeners(java.lang.String evtnm)
Description copied from interface:PageReturns an iterable collection of the event listeners for the given event.Note: it is OK to invoke
Page.addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)orPage.removeEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener<? extends org.zkoss.zk.ui.event.Event>)when iterating through the event listeners with the returned collection.To remove an event listener from the returned iterable collection, you could invoke
Iterable.iterator()'sIterator.remove().- Specified by:
getEventListenersin interfacePage
-
getOwner
public final Component getOwner()
Description copied from interface:PageCtrlReturns 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.Note: the owner, if not null, must implement
Includer.
-
setOwner
public final void setOwner(Component comp)
Description copied from interface:PageCtrlSets the owner of this page.Called only internally
Since 5.0.6, the owner must implement
Includer.
-
sessionWillPassivate
public void sessionWillPassivate(Desktop desktop)
Description copied from interface:PageCtrlNotification that the session, which owns this page, is about to be passivated (a.k.a., serialized).- Specified by:
sessionWillPassivatein interfacePageCtrl
-
sessionDidActivate
public void sessionDidActivate(Desktop desktop)
Description copied from interface:PageCtrlNotification that the session, which owns this page, has just been activated (a.k.a., deserialized).- Specified by:
sessionDidActivatein interfacePageCtrl
-
getLanguageDefinition
public LanguageDefinition getLanguageDefinition()
Description copied from interface:PageReturns the language definition that this page belongs to (never null).- Specified by:
getLanguageDefinitionin interfacePage
-
getComponentDefinitionMap
public ComponentDefinitionMap getComponentDefinitionMap()
Description copied from interface:PageReturns 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:
getComponentDefinitionMapin interfacePage
-
getComponentDefinition
public ComponentDefinition getComponentDefinition(java.lang.String name, boolean recurse)
Description copied from interface:PageReturns 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:
getComponentDefinitionin interfacePagerecurse- whether to look up the component fromPage.getLanguageDefinition()
-
getComponentDefinition
public ComponentDefinition getComponentDefinition(java.lang.Class<? extends Component> cls, boolean recurse)
Description copied from interface:PageReturns 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:
getComponentDefinitionin interfacePagerecurse- whether to look up the component fromPage.getLanguageDefinition()
-
getExpressionFactoryClass
public java.lang.Class<? extends org.zkoss.xel.ExpressionFactory> getExpressionFactoryClass()
Description copied from interface:PageReturns the implementation of the expression factory that is used by this page, or null ifConfiguration.getExpressionFactoryClass()is used.Default: null.
- Specified by:
getExpressionFactoryClassin interfacePage- See Also:
Page.setExpressionFactoryClass(java.lang.Class<? extends org.zkoss.xel.ExpressionFactory>)
-
setExpressionFactoryClass
public void setExpressionFactoryClass(java.lang.Class<? extends org.zkoss.xel.ExpressionFactory> expfcls)
Description copied from interface:PageSets the implementation of the expression factory that is used by this page.- Specified by:
setExpressionFactoryClassin interfacePage- Parameters:
expfcls- the class that implementsExpressionFactory, If null,Configuration.getExpressionFactoryClass()is used.- See Also:
Page.getExpressionFactoryClass()
-
addTemplate
public void addTemplate(java.lang.String name, Template template)Description copied from interface:PageAdds page scope template- Specified by:
addTemplatein interfacePage
-
removeTemplate
public void removeTemplate(java.lang.String name)
Description copied from interface:PageRemoves page scope template- Specified by:
removeTemplatein interfacePage
-
getTemplate
public Template getTemplate(java.lang.String name)
Description copied from interface:PageGets page scope template by name- Specified by:
getTemplatein interfacePage
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-