Class PageDefinition
- All Implemented Interfaces:
NodeInfo
Note: it is not thread-safe.
Note: it is not serializable.
- Author:
- tomyeh
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPageDefinition(LanguageDefinition langdef, String id, String title, String style, org.zkoss.util.resource.Locator locator) Constructor.PageDefinition(LanguageDefinition langdef, org.zkoss.util.resource.Locator locator) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a component definition belonging to this page definition only.voidaddExpressionImport(String nm, Class<?> cls) Adds an imported class to the expression factory.voidaddForwardInfo(ForwardInfo forward) Adds a forward definition (ForwardInfo).voidAdds a definition ofFunctionMapper.voidaddHeaderInfo(HeaderInfo header) Adds a header definition (HeaderInfo).voidaddHeaderInfo(HeaderInfo header, boolean before) Adds a header definition (HeaderInfo).voidaddImportedClass(String clsptn) Adds an imported class Like Java, it is used to import a class or a package of classes, so that it simplifies the use of the apply attribute, the init directive and others.voidAdds a definition ofInitiator.voidAdds a response header.voidaddTaglib(org.zkoss.xel.taglib.Taglib taglib) Adds a tag lib.voidaddTemplateInfo(TemplateInfo info) Adds a template info The previous src of the same name will be replaced.voidaddVariableResolverInfo(VariableResolverInfo resolver) Adds a definition ofVariableResolver.voidaddXelMethod(String prefix, String name, org.zkoss.xel.Function func) Adds a XEL method.voidappendChild(NodeInfo child) Append a childReturns a list of allInitiatorand invokes itsInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)before returning.getAfterHeadTags(Page page) Returns the content that shall be generated inside the head element and after ZK's default tags (never null).Returns whether to automatically redirect to the timeout URI.getBeforeHeadTags(Page page) Returns the content that shall be generated inside the head element and before ZK's default tags (never null).Returns if the client can cache the rendered result, or null to use the device default.Returns a readonly list of children.getComponentDefinition(Class cls, boolean recurse) Returns the component definition of the specified class, or null if not found.getComponentDefinition(String name, boolean recurse) Returns the component definition of the specified name, or null if not found.Returns the map of component definition (never null).getContentType(Page page) Returns the content type (after evaluation), or null to use the device default.getDocType(Page page) Returns the doc type (<!Returns the evaluator.Returns the evaluator reference.Class<? extends org.zkoss.xel.ExpressionFactory>Returns the implementation of the expression factory that is used by this page, or null ifConfiguration.getExpressionFactoryClass()is used.getFirstLine(Page page) Returns the first line to be generated to the output (after evaluation), or null if nothing to generate.getForwardURI(Page page) Returns the URI to forward to, or null if not to forward.getId()Returns the identifier that will be assigned to pages created from this definition, or null if the identifier shall be generated automatically.Returns a readonly list of the imported class names.org.zkoss.lang.ClassResolverReturns the class resolver represented bygetImportedClasses().Returns the language definition that this page is default to be.org.zkoss.util.resource.LocatorReturns the locator associated with this page definition.Returns the page definition (always this).Returns the parent (always null).Returns the request path of this page definition, or "" if not available.Collection<Object[]>getResponseHeaders(Page page) Returns a map of response headers (never null).getRootAttributes(Page page) Converts the header definitions (added bysetRootAttribute(java.lang.String, java.lang.String)) to the attributes of the root element.getStyle()Returns the CSS style that will be assigned to pages created from this definition, or null if no style is assigned at the beginning.org.zkoss.xel.FunctionMapperReturns the mapper representing the functions defined in taglib and xel-method.Gets templates info mapgetTitle()Returns the title that will be assigned to pages created from this definition, or null if no title is assigned at the beginning.Returns the viewport that will be assigned to pages created from this definition, or "auto" if no viewport is assigned at the beginning.getWidgetClass(Page page) Returns the widget class of the given page, or null if the default is used.Returns the default scripting language which is assumed when a zscript element doesn't specify any language.voidimports(PageDefinition pgdef) Imports the init directives and component definitions from the specified page definition.voidimports(PageDefinition pgdef, String[] directives) Imports the specified directives from the specified page definition.voidInitializes a page after execution is activated.booleanReturns if the page is a complete page.voidInitializes the context for the given page before rendering this page definition.booleanremoveChild(NodeInfo child) Removes a child.voidsetAutomaticTimeout(Boolean autoTimeout) Sets whether to automatically redirect to the timeout URI.voidsetCacheable(Boolean cacheable) Sets if the client can cache the rendered result.voidsetComplete(boolean complete) Sets if the page is a complete page.voidsetContentType(String contentType) Sets the content type.voidsetDocType(String docType) Sets the doc type (<!voidsetExpressionFactoryClass(Class<?> expfcls) Sets the implementation of the expression factory that shall be used by this page.voidsetFirstLine(String firstLine) Sets the first line to be generated to the output.voidSets the identifier that will be assigned to pages created from this definition.voidsetRequestPath(String path) Sets the request path of this page definition.voidsetRootAttribute(String name, String value) Adds a root attribute.voidSets the CSS style that will be assigned to pages created from this definition, or null if no style is assigned at the beginning.voidSets the title that will be assigned to pages created from this definition, or null if no title is assigned at the beginning.voidsetViewport(String viewport) Sets the viewport that will be assigned to pages created from this definition, or "auto" if no viewport is assigned at the beginning.voidsetWidgetClass(String wgtcls) Sets the widget class of the page.voidsetZScriptLanguage(String zslang) Sets the default scripting language which is assumed when a zscript element doesn't specify any language.toString()
-
Constructor Details
-
PageDefinition
Constructor.- Parameters:
langdef- the default language which is used if no namespace is specified. Note: a page might have components from different languages.
-
PageDefinition
public PageDefinition(LanguageDefinition langdef, String id, String title, String style, org.zkoss.util.resource.Locator locator) Constructor.- Parameters:
langdef- the default language which is used if no namespace is specified. Note: a page might have components from different languages.id- the identifier. SeesetId(java.lang.String).title- the title. SeesetTitle(java.lang.String).style- the CSS style. SeesetStyle(java.lang.String).
-
-
Method Details
-
getLanguageDefinition
Returns the language definition that this page is default to be. -
getLocator
public org.zkoss.util.resource.Locator getLocator()Returns the locator associated with this page definition. -
getZScriptLanguage
Returns the default scripting language which is assumed when a zscript element doesn't specify any language.Default: Java.
-
setZScriptLanguage
Sets the default scripting language which is assumed when a zscript element doesn't specify any language.- Parameters:
zslang- the default scripting language.
-
getId
Returns the identifier that will be assigned to pages created from this definition, or null if the identifier shall be generated automatically.Note: the returned value might contain EL expressions.
-
setId
Sets the identifier that will be assigned to pages created from this definition.- Parameters:
id- the identifier. It might contain EL expressions. If null or empty (null is assumed), page's ID is generated automatically. If not empty, ID (after evaluated) must be unique in the same request.
-
getTitle
Returns the title that will be assigned to pages created from this definition, or null if no title is assigned at the beginning.Note: the returned value might contain EL expressions.
-
setTitle
Sets the title that will be assigned to pages created from this definition, or null if no title is assigned at the beginning.- Parameters:
title- the title. If empty, null is assumed.
-
getStyle
Returns the CSS style that will be assigned to pages created from this definition, or null if no style is assigned at the beginning.Note: the returned value might contain EL expressions.
-
setStyle
Sets the CSS style that will be assigned to pages created from this definition, or null if no style is assigned at the beginning.- Parameters:
style- the CSS style. If empty, null is assumed.
-
getViewport
Returns the viewport that will be assigned to pages created from this definition, or "auto" if no viewport is assigned at the beginning.Note: the returned value might contain EL expressions.
- Since:
- 6.5.0
-
setViewport
Sets the viewport that will be assigned to pages created from this definition, or "auto" if no viewport is assigned at the beginning.- Parameters:
viewport- the viewport setting. If empty, "auto" is assumed.- Since:
- 6.5.0
-
getWidgetClass
Returns the widget class of the given page, or null if the default is used.- Since:
- 5.0.5
-
setWidgetClass
Sets the widget class of the page.- Parameters:
wgtcls- the widget class. It may contain EL expressions. If null or empty, the default widget class is assumed.- Since:
- 5.0.5
-
getRequestPath
Returns the request path of this page definition, 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.
-
setRequestPath
Sets the request path of this page definition. -
imports
Imports the specified directives from the specified page definition.- Parameters:
pgdef- the page definition to import from.directives- an array of the directive names to import. If null, {"init", "component"} is assumed, i.e., only the init directives and component definitions are imported.
Importable directives include "component", "init", "meta", "taglib", "variable-resolver", and "xel-method". If "*", all of them are imported. Note: "meta" implies "link".- Since:
- 3.0.2
-
imports
Imports the init directives and component definitions from the specified page definition.It is the same as imports(pgdef, null).
- Since:
- #imports(PageDefinition, String[])
-
addImportedClass
Adds an imported class Like Java, it is used to import a class or a package of classes, so that it simplifies the use of the apply attribute, the init directive and others.- Parameters:
clsptn- the class's fully-qualified name, e.g.,com.foo.FooComposer, a wildcard representing all classes of the give package, e.g.,com.foo.*.- Throws:
ClassNotFoundException- Since:
- 6.0.0
-
getImportedClasses
Returns a readonly list of the imported class names.- Since:
- 6.0.0
-
getImportedClassResolver
public org.zkoss.lang.ClassResolver getImportedClassResolver()Returns the class resolver represented bygetImportedClasses().- Since:
- 6.0.0
-
addInitiatorInfo
Adds a definition ofInitiator. -
doInit
Returns a list of allInitiatorand invokes itsInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)before returning. It never returns null. -
addVariableResolverInfo
Adds a definition ofVariableResolver. -
addFunctionMapperInfo
Adds a definition ofFunctionMapper.- Since:
- 3.5.0
-
addXelMethod
Adds a XEL method.- Parameters:
prefix- the prefix of the method namename- the method name. The final name is "prefix:name"func- the function.- Since:
- 3.0.0
-
addResponseHeaderInfo
Adds a response header.- Since:
- 5.0.2
-
getResponseHeaders
Returns a map of response headers (never null). The value of each entry is a two-element object array. The first element of the array is the value which is an instance ofDateorString(and never null). The second element indicates whether to add (rather than set) header. It is an instance of Boolean (and never null). -
addHeaderInfo
Adds a header definition (HeaderInfo).- Parameters:
before- whether to place the header before ZK's CSS/JS headers. If false, it is placed after ZK's CSS/JS headers.- Since:
- 3.6.1
-
addHeaderInfo
Adds a header definition (HeaderInfo). It places the meta headers before ZK's CSS/JS headers, and others after ZK's CSS/JS headers. -
getBeforeHeadTags
Returns the content 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.
- Since:
- 5.0.5
- See Also:
-
getAfterHeadTags
Returns the content 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.
- Since:
- 5.0.5
- See Also:
-
addForwardInfo
Adds a forward definition (ForwardInfo). -
getForwardURI
Returns the URI to forward to, or null if not to forward. It evaluates the forward definition (added byaddForwardInfo(org.zkoss.zk.ui.metainfo.ForwardInfo)) one-by-one, if any, to see whether to forward. Returns null if no forward definition, or no forward definition's condition is satisfied. -
getContentType
Returns the content type (after evaluation), or null to use the device default.- Parameters:
page- the page used to evaluate EL expressions, if any- Since:
- 3.0.0
-
setContentType
Sets the content type.Default: null (use the device default).
- Parameters:
contentType- the content type. It may contain EL expressions.- Since:
- 3.0.0
-
getDocType
Returns the doc type (<!DOCTYPE>) (after evaluation), or null to use the device default.- Parameters:
page- the page used to evaluate EL expressions, if any- Since:
- 3.0.0
-
setDocType
Sets the doc type (<!DOCTYPE>).Default: null (use the device default).
- Parameters:
docType- the doc type. It may contain EL expressions. If null, it means device's default will be used. If empty, it means no doc type will be generated.- Since:
- 3.0.0
-
getFirstLine
Returns the first line to be generated to the output (after evaluation), or null if nothing to generate.For XML devices, it is usually the xml processing instruction:
<?xml version="1.0" encoding="UTF-8"?>- Parameters:
page- the page used to evaluate EL expressions, if any- Since:
- 3.0.0
-
setFirstLine
Sets the first line to be generated to the output.Default: null (i.e., nothing generated)
- Since:
- 3.0.0
-
getCacheable
Returns if the client can cache the rendered result, or null to use the device default.- Since:
- 3.0.0
-
setCacheable
Sets if the client can cache the rendered result.Default: null (use the device default).
- Since:
- 3.0.0
-
getAutomaticTimeout
Returns whether to automatically redirect to the timeout URI.- Since:
- 3.6.3
- See Also:
-
setAutomaticTimeout
Sets whether to automatically redirect to the timeout URI.Default: null (use the device default). Refer to
Configuration.setAutomaticTimeout(java.lang.String, boolean)for details.- Since:
- 3.6.3
-
isComplete
public boolean isComplete()Returns if the page is a complete page. By complete we mean the page has everything that the client expects. For example, for HTML output, the page will generate the HTML, HEAD and BODY tags.By default (false), we assume a page is complete if and only if it is not included by other page.
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.
- Since:
- 3.0.4
-
setComplete
public void setComplete(boolean complete) 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.
- 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.- Since:
- 3.0.4
- See Also:
-
setRootAttribute
Adds a root attribute. The previous attribute of the same name will be replaced.- Parameters:
value- the value. If null, the attribute is removed. It can be an EL expression.- Since:
- 3.0.0
-
getRootAttributes
Converts the header definitions (added bysetRootAttribute(java.lang.String, java.lang.String)) to the attributes of the root element. For HTML, the root element is the HTML element.- Since:
- 3.0.0
-
getComponentDefinitionMap
Returns the map of component definition (never null). -
addComponentDefinition
Adds a component definition belonging to this page definition only.It is the same as calling
ComponentDefinitionMap.add(org.zkoss.zk.ui.metainfo.ComponentDefinition)againstgetComponentDefinitionMap() -
getComponentDefinition
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.- Parameters:
recurse- whether to look up the component fromgetLanguageDefinition()
-
getComponentDefinition
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.- Parameters:
recurse- whether to look up the component fromgetLanguageDefinition()
-
addTaglib
public void addTaglib(org.zkoss.xel.taglib.Taglib taglib) Adds a tag lib. -
addExpressionImport
Adds an imported class to the expression factory.- Since:
- 3.0.0
-
setExpressionFactoryClass
Sets the implementation of the expression factory that shall be used by this page.Default: null (use the default).
- Parameters:
expfcls- the implementation class, or null to use the default. Note: expfcls must implementExpressionFactory. If null is specified, the class defined inConfiguration.getExpressionFactoryClass()- Throws:
IllegalArgumentException- if expfcls does not implement ExpressionFactory- Since:
- 3.0.0
-
getExpressionFactoryClass
Returns the implementation of the expression factory that is used by this page, or null ifConfiguration.getExpressionFactoryClass()is used.- Since:
- 3.0.0
- See Also:
-
getEvaluator
Description copied from interface:NodeInfoReturns the evaluator.All nodes in the same ZUML tree has the same evaluator reference (inherited from the root node,
getEvaluatorRef()).- Specified by:
getEvaluatorin interfaceNodeInfo
-
getEvaluatorRef
Description copied from interface:NodeInfoReturns the evaluator reference.- Specified by:
getEvaluatorRefin interfaceNodeInfo
-
getTaglibMapper
public org.zkoss.xel.FunctionMapper getTaglibMapper()Returns the mapper representing the functions defined in taglib and xel-method.Note: it doesn't include the function mapper defined added by
addFunctionMapperInfo(org.zkoss.zk.ui.metainfo.FunctionMapperInfo).- Since:
- 3.5.0
-
addTemplateInfo
Adds a template info The previous src of the same name will be replaced.- Parameters:
info- the src. If null, the attribute is removed.- Since:
- 8.0.0
-
getTemplatesInfo
Gets templates info map- Since:
- 8.0.0
-
preInit
Initializes the context for the given page before rendering this page definition.It is called before
Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)andinit(org.zkoss.zk.ui.Page, boolean).- Parameters:
page- the page to initialize the context. It cannot be null.
-
init
Initializes a page after execution is activated. It setup the identifier and title, and adds it to desktop.It is called after
preInit(org.zkoss.zk.ui.Page)andInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>). -
getParent
Returns the parent (always null). -
getPageDefinition
Returns the page definition (always this).- Specified by:
getPageDefinitionin interfaceNodeInfo
-
appendChild
Description copied from interface:NodeInfoAppend a child- Specified by:
appendChildin interfaceNodeInfo
-
removeChild
Description copied from interface:NodeInfoRemoves a child.- Specified by:
removeChildin interfaceNodeInfo
-
getChildren
Description copied from interface:NodeInfoReturns a readonly list of children.Note: the returned list is readonly. To modify, please use
NodeInfo.appendChild(org.zkoss.zk.ui.metainfo.NodeInfo)andNodeInfo.removeChild(org.zkoss.zk.ui.metainfo.NodeInfo)instead.- Specified by:
getChildrenin interfaceNodeInfo
-
toString
-