public class PageDefinition extends java.lang.Object implements NodeInfo
Note: it is not thread-safe.
Note: it is not serializable.
ComponentDefinition
Constructor and Description |
---|
PageDefinition(LanguageDefinition langdef,
Locator locator)
Constructor.
|
PageDefinition(LanguageDefinition langdef,
java.lang.String id,
java.lang.String title,
java.lang.String style,
Locator locator)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponentDefinition(ComponentDefinition compdef)
Adds a component definition belonging to this page definition only.
|
void |
addExpressionImport(java.lang.String nm,
java.lang.Class<?> cls)
Adds an imported class to the expression factory.
|
void |
addForwardInfo(ForwardInfo forward)
Adds a forward definition (
ForwardInfo ). |
void |
addFunctionMapperInfo(FunctionMapperInfo mapper)
Adds a definition of
FunctionMapper . |
void |
addHeaderInfo(HeaderInfo header)
Adds a header definition (
HeaderInfo ). |
void |
addHeaderInfo(HeaderInfo header,
boolean before)
Adds a header definition (
HeaderInfo ). |
void |
addImportedClass(java.lang.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.
|
void |
addInitiatorInfo(InitiatorInfo init)
Adds a definition of
Initiator . |
void |
addResponseHeaderInfo(ResponseHeaderInfo header)
Adds a response header.
|
void |
addTaglib(Taglib taglib)
Adds a tag lib.
|
void |
addTemplateInfo(TemplateInfo info)
Adds a template info
The previous src of the same name will be replaced.
|
void |
addVariableResolverInfo(VariableResolverInfo resolver)
Adds a definition of
VariableResolver . |
void |
addXelMethod(java.lang.String prefix,
java.lang.String name,
Function func)
Adds a XEL method.
|
void |
appendChild(NodeInfo child)
Append a child
|
java.util.List<Initiator> |
doInit(Page page)
Returns a list of all
Initiator and invokes
its Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>) before returning. |
java.lang.String |
getAfterHeadTags(Page page)
Returns the content that shall be generated inside the head element
and after ZK's default tags (never null).
|
java.lang.Boolean |
getAutomaticTimeout()
Returns whether to automatically redirect to the timeout URI.
|
java.lang.String |
getBeforeHeadTags(Page page)
Returns the content that shall be generated inside the head element
and before ZK's default tags (never null).
|
java.lang.Boolean |
getCacheable()
Returns if the client can cache the rendered result, or null
to use the device default.
|
java.util.List<NodeInfo> |
getChildren()
Returns a readonly list of children.
|
ComponentDefinition |
getComponentDefinition(java.lang.Class cls,
boolean recurse)
Returns the component definition of the specified class, or null
if not found.
|
ComponentDefinition |
getComponentDefinition(java.lang.String name,
boolean recurse)
Returns the component definition of the specified name, or null
if not found.
|
ComponentDefinitionMap |
getComponentDefinitionMap()
Returns the map of component definition (never null).
|
java.lang.String |
getContentType(Page page)
Returns the content type (after evaluation),
or null to use the device default.
|
java.lang.String |
getDocType(Page page)
Returns the doc type (<!
|
Evaluator |
getEvaluator()
Returns the evaluator.
|
EvaluatorRef |
getEvaluatorRef()
Returns the evaluator reference.
|
java.lang.Class<? extends ExpressionFactory> |
getExpressionFactoryClass()
Returns the implementation of the expression factory that
is used by this page, or null if
Configuration.getExpressionFactoryClass()
is used. |
java.lang.String |
getFirstLine(Page page)
Returns the first line to be generated to the output
(after evaluation), or null if nothing to generate.
|
java.lang.String |
getForwardURI(Page page)
Returns the URI to forward to, or null if not to forward.
|
java.lang.String |
getId()
Returns the identifier that will be assigned to pages created from
this definition, or null if the identifier shall be generated automatically.
|
java.util.List<java.lang.String> |
getImportedClasses()
Returns a readonly list of the imported class names.
|
ClassResolver |
getImportedClassResolver()
Returns the class resolver represented by
getImportedClasses() . |
LanguageDefinition |
getLanguageDefinition()
Returns the language definition that this page is default to be.
|
Locator |
getLocator()
Returns the locator associated with this page definition.
|
PageDefinition |
getPageDefinition()
Returns the page definition (always this).
|
NodeInfo |
getParent()
Returns the parent (always null).
|
java.lang.String |
getRequestPath()
Returns the request path of this page definition, or ""
if not available.
|
java.util.Collection<java.lang.Object[]> |
getResponseHeaders(Page page)
Returns a map of response headers (never null).
|
java.lang.String |
getRootAttributes(Page page)
Converts the header definitions (added by
setRootAttribute(java.lang.String, java.lang.String) )
to the attributes of the root element. |
java.lang.String |
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.
|
FunctionMapper |
getTaglibMapper()
Returns the mapper representing the functions defined in
taglib and xel-method.
|
java.util.Map<java.lang.String,TemplateInfo> |
getTemplatesInfo()
Gets templates info map
|
java.lang.String |
getTitle()
Returns the title that will be assigned to pages created from
this definition, or null if no title is assigned at the beginning.
|
java.lang.String |
getViewport()
Returns the viewport that will be assigned to pages created from
this definition, or "auto" if no viewport is assigned at the beginning.
|
java.lang.String |
getWidgetClass(Page page)
Returns the widget class of the given page, or null if the default is used.
|
java.lang.String |
getZScriptLanguage()
Returns the default scripting language which is assumed when
a zscript element doesn't specify any language.
|
void |
imports(PageDefinition pgdef)
Imports the init directives and component definitions from
the specified page definition.
|
void |
imports(PageDefinition pgdef,
java.lang.String[] directives)
Imports the specified directives from the specified page definition.
|
void |
init(Page page,
boolean evalHeaders)
Initializes a page after execution is activated.
|
boolean |
isComplete()
Returns if the page is a complete page.
|
void |
preInit(Page page)
Initializes the context for the given page before rendering
this page definition.
|
boolean |
removeChild(NodeInfo child)
Removes a child.
|
void |
setAutomaticTimeout(java.lang.Boolean autoTimeout)
Sets whether to automatically redirect to the timeout URI.
|
void |
setCacheable(java.lang.Boolean cacheable)
Sets if the client can cache the rendered result.
|
void |
setComplete(boolean complete)
Sets if the page is a complete page.
|
void |
setContentType(java.lang.String contentType)
Sets the content type.
|
void |
setDocType(java.lang.String docType)
Sets the doc type (<!
|
void |
setExpressionFactoryClass(java.lang.Class<?> expfcls)
Sets the implementation of the expression factory that shall
be used by this page.
|
void |
setFirstLine(java.lang.String firstLine)
Sets the first line to be generated to the output.
|
void |
setId(java.lang.String id)
Sets the identifier that will be assigned to pages created from this
definition.
|
void |
setRequestPath(java.lang.String path)
Sets the request path of this page definition.
|
void |
setRootAttribute(java.lang.String name,
java.lang.String value)
Adds a root attribute.
|
void |
setStyle(java.lang.String style)
Sets the CSS style that will be assigned to pages created from
this definition, or null if no style is assigned at the beginning.
|
void |
setTitle(java.lang.String title)
Sets the title that will be assigned to pages created from
this definition, or null if no title is assigned at the beginning.
|
void |
setViewport(java.lang.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.
|
void |
setWidgetClass(java.lang.String wgtcls)
Sets the widget class of the page.
|
void |
setZScriptLanguage(java.lang.String zslang)
Sets the default scripting language which is assumed when
a zscript element doesn't specify any language.
|
java.lang.String |
toString() |
public PageDefinition(LanguageDefinition langdef, Locator locator)
langdef
- the default language which is used if no namespace
is specified. Note: a page might have components from different
languages.public PageDefinition(LanguageDefinition langdef, java.lang.String id, java.lang.String title, java.lang.String style, Locator locator)
langdef
- the default language which is used if no namespace
is specified. Note: a page might have components from different
languages.id
- the identifier. See setId(java.lang.String)
.title
- the title. See setTitle(java.lang.String)
.style
- the CSS style. See setStyle(java.lang.String)
.public LanguageDefinition getLanguageDefinition()
public Locator getLocator()
public java.lang.String getZScriptLanguage()
Default: Java.
public void setZScriptLanguage(java.lang.String zslang)
zslang
- the default scripting language.public java.lang.String getId()
Note: the returned value might contain EL expressions.
public void setId(java.lang.String id)
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.public java.lang.String getTitle()
Note: the returned value might contain EL expressions.
public void setTitle(java.lang.String title)
title
- the title. If empty, null is assumed.public java.lang.String getStyle()
Note: the returned value might contain EL expressions.
public void setStyle(java.lang.String style)
style
- the CSS style. If empty, null is assumed.public java.lang.String getViewport()
Note: the returned value might contain EL expressions.
public void setViewport(java.lang.String viewport)
viewport
- the viewport setting. If empty, "auto" is assumed.public java.lang.String getWidgetClass(Page page)
public void setWidgetClass(java.lang.String wgtcls)
wgtcls
- the widget class. It may contain EL expressions.
If null or empty, the default widget class is assumed.public java.lang.String getRequestPath()
It is the same as the servlet path (javax.servlet.http.HttpServletRequest's getServletPath), if ZK is running at a servlet container.
public void setRequestPath(java.lang.String path)
public void imports(PageDefinition pgdef, java.lang.String[] directives)
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.public void imports(PageDefinition pgdef)
It is the same as imports(pgdef, null).
public void addImportedClass(java.lang.String clsptn) throws java.lang.ClassNotFoundException
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.*
.java.lang.ClassNotFoundException
public java.util.List<java.lang.String> getImportedClasses()
public ClassResolver getImportedClassResolver()
getImportedClasses()
.public void addInitiatorInfo(InitiatorInfo init)
Initiator
.public java.util.List<Initiator> doInit(Page page)
Initiator
and invokes
its Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)
before returning.
It never returns null.public void addVariableResolverInfo(VariableResolverInfo resolver)
VariableResolver
.public void addFunctionMapperInfo(FunctionMapperInfo mapper)
FunctionMapper
.public void addXelMethod(java.lang.String prefix, java.lang.String name, Function func)
prefix
- the prefix of the method namename
- the method name. The final name is "prefix:name"func
- the function.public void addResponseHeaderInfo(ResponseHeaderInfo header)
public java.util.Collection<java.lang.Object[]> getResponseHeaders(Page page)
Date
or String
(and never null).
The second element indicates whether to add (rather than set)
header. It is an instance of Boolean (and never null).public void addHeaderInfo(HeaderInfo header, boolean before)
HeaderInfo
).before
- whether to place the header before ZK's
CSS/JS headers. If false, it is placed after ZK's CSS/JS headers.public void addHeaderInfo(HeaderInfo header)
HeaderInfo
).
It places the meta headers before ZK's CSS/JS headers,
and others after ZK's CSS/JS headers.public java.lang.String getBeforeHeadTags(Page page)
Since it is generated before ZK's default tags (such as CSS and JS), it cannot override ZK's default behaviors.
getAfterHeadTags(org.zkoss.zk.ui.Page)
public java.lang.String getAfterHeadTags(Page page)
Since it is generated after ZK's default tags (such as CSS and JS), it could override ZK's default behaviors.
getBeforeHeadTags(org.zkoss.zk.ui.Page)
public void addForwardInfo(ForwardInfo forward)
ForwardInfo
).public java.lang.String getForwardURI(Page page)
addForwardInfo(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.public java.lang.String getContentType(Page page)
page
- the page used to evaluate EL expressions, if anypublic void setContentType(java.lang.String contentType)
Default: null (use the device default).
contentType
- the content type. It may contain EL expressions.public java.lang.String getDocType(Page page)
page
- the page used to evaluate EL expressions, if anypublic void setDocType(java.lang.String docType)
Default: null (use the device default).
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.public java.lang.String getFirstLine(Page page)
For XML devices, it is usually the xml processing instruction:
<?xml version="1.0" encoding="UTF-8"?>
page
- the page used to evaluate EL expressions, if anypublic void setFirstLine(java.lang.String firstLine)
Default: null (i.e., nothing generated)
public java.lang.Boolean getCacheable()
public void setCacheable(java.lang.Boolean cacheable)
Default: null (use the device default).
public java.lang.Boolean getAutomaticTimeout()
setAutomaticTimeout(java.lang.Boolean)
public void setAutomaticTimeout(java.lang.Boolean autoTimeout)
Default: null (use the device default).
Refer to Configuration.setAutomaticTimeout(java.lang.String, boolean)
for details.
public boolean isComplete()
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.
public void setComplete(boolean complete)
Default: false. It means a page is complete if and only if it is not included by other page.
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.isComplete()
public void setRootAttribute(java.lang.String name, java.lang.String value)
value
- the value. If null, the attribute is removed.
It can be an EL expression.public java.lang.String getRootAttributes(Page page)
setRootAttribute(java.lang.String, java.lang.String)
)
to the attributes of the root element.
For HTML, the root element is the HTML element.public ComponentDefinitionMap getComponentDefinitionMap()
public void addComponentDefinition(ComponentDefinition compdef)
It is the same as calling ComponentDefinitionMap.add(org.zkoss.zk.ui.metainfo.ComponentDefinition)
against getComponentDefinitionMap()
public ComponentDefinition getComponentDefinition(java.lang.String name, boolean recurse)
Note: unlike LanguageDefinition.getComponentDefinition(java.lang.String)
,
this method doesn't throw ComponentNotFoundException if not found.
It just returns null.
recurse
- whether to look up the component from getLanguageDefinition()
public ComponentDefinition getComponentDefinition(java.lang.Class cls, boolean recurse)
Note: unlike LanguageDefinition.getComponentDefinition(java.lang.String)
,
this method doesn't throw ComponentNotFoundException if not found.
It just returns null.
recurse
- whether to look up the component from getLanguageDefinition()
public void addTaglib(Taglib taglib)
public void addExpressionImport(java.lang.String nm, java.lang.Class<?> cls)
public void setExpressionFactoryClass(java.lang.Class<?> expfcls)
Default: null (use the default).
expfcls
- the implementation class, or null to use the default.
Note: expfcls must implement ExpressionFactory
.
If null is specified, the class defined in
Configuration.getExpressionFactoryClass()
java.lang.IllegalArgumentException
- if expfcls does not implement ExpressionFactorypublic java.lang.Class<? extends ExpressionFactory> getExpressionFactoryClass()
Configuration.getExpressionFactoryClass()
is used.setExpressionFactoryClass(java.lang.Class<?>)
public Evaluator getEvaluator()
NodeInfo
All nodes in the same ZUML tree has the same evaluator reference
(inherited from the root node, getEvaluatorRef()
).
getEvaluator
in interface NodeInfo
public EvaluatorRef getEvaluatorRef()
NodeInfo
getEvaluatorRef
in interface NodeInfo
public FunctionMapper getTaglibMapper()
Note: it doesn't include the function mapper defined added by
addFunctionMapperInfo(org.zkoss.zk.ui.metainfo.FunctionMapperInfo)
.
public void addTemplateInfo(TemplateInfo info)
info
- the src. If null, the attribute is removed.public java.util.Map<java.lang.String,TemplateInfo> getTemplatesInfo()
public void preInit(Page page)
It is called before Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)
and init(org.zkoss.zk.ui.Page, boolean)
.
page
- the page to initialize the context. It cannot be null.public void init(Page page, boolean evalHeaders)
It is called after preInit(org.zkoss.zk.ui.Page)
and Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)
.
public NodeInfo getParent()
public PageDefinition getPageDefinition()
getPageDefinition
in interface NodeInfo
public void appendChild(NodeInfo child)
NodeInfo
appendChild
in interface NodeInfo
public boolean removeChild(NodeInfo child)
NodeInfo
removeChild
in interface NodeInfo
public java.util.List<NodeInfo> getChildren()
NodeInfo
Note: the returned list is readonly. To modify, please use
NodeInfo.appendChild(org.zkoss.zk.ui.metainfo.NodeInfo)
and NodeInfo.removeChild(org.zkoss.zk.ui.metainfo.NodeInfo)
instead.
getChildren
in interface NodeInfo
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.