org.zkoss.zk.ui.metainfo
Class PageDefinition

java.lang.Object
  extended by org.zkoss.zk.ui.metainfo.NodeInfo
      extended by org.zkoss.zk.ui.metainfo.PageDefinition

public class PageDefinition
extends NodeInfo

A page definition. It represents a ZUL page.

Note: it is not thread-safe.

Note: it is not serializable.

Author:
tomyeh
See Also:
ComponentDefinition

Constructor Summary
PageDefinition(LanguageDefinition langdef, org.zkoss.util.resource.Locator locator)
          Constructor.
PageDefinition(LanguageDefinition langdef, java.lang.String id, java.lang.String title, java.lang.String style, org.zkoss.util.resource.Locator locator)
          Constructor.
 
Method Summary
 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 addHeaderInfo(HeaderInfo header)
          Adds a header definition (HeaderInfo).
 void addInitiatorInfo(InitiatorInfo init)
          Adds a defintion of Initiator.
 void addTaglib(org.zkoss.xel.taglib.Taglib taglib)
          Adds a tag lib.
 void addVariableResolverInfo(VariableResolverInfo resolver)
          Adds a defintion of VariableResolver.
 void addXelMethod(java.lang.String prefix, java.lang.String name, org.zkoss.xel.Function func)
          Adds a XEL method.
 java.util.List doInit(Page page)
          Returns a list of all Initiator and invokes its Initiator.doInit(org.zkoss.zk.ui.Page, java.lang.Object[]) before returning.
 java.lang.Boolean getCacheable()
          Returns if the client can cache the rendered result, or null to use the device default.
 ComponentDefinition getComponentDefinition(java.lang.Class cls, boolean recur)
          Returns the component definition of the specified class, or null if not found.
 ComponentDefinition getComponentDefinition(java.lang.String name, boolean recur)
          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 based on this page definition (never null).
 EvaluatorRef getEvaluatorRef()
          Returns the evaluator reference (never null).
 java.lang.Class getExpressionFactoryClass()
          Returns the implementation of the expression factory that is used by this page, or null if Configuration.getExpressionFactoryClass() is used.
 java.lang.String getFirstLine(Page page)
          Returns the first line to be generated to the output (after evaluation), or null if nothing to generate.
 org.zkoss.xel.FunctionMapper getFunctionMapper()
          Returns the function mapper, or null if no mappter at all.
 java.lang.String getHeaders(Page page)
          Converts the header definitions (added by addHeaderInfo(org.zkoss.zk.ui.metainfo.HeaderInfo)) to HTML tags.
 java.lang.String getId()
          Returns the identitifer that will be assigned to pages created from this definition, or null if the identifier shall be generated automatically.
 LanguageDefinition getLanguageDefinition()
          Returns the language definition that this page is default to be.
 org.zkoss.util.resource.Locator getLocator()
          Returns the locator associated with this page definition.
 PageDefinition getPageDefinition()
          Returns the page definition, or null if not available.
 NodeInfo getParent()
          Returns the parent (always null).
 java.lang.String getRequestPath()
          Returns the request path of this page definition, or "" if not available.
 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.
 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 getZScriptLanguage()
          Returns the default scripting language which is assumed when a zscript element doesn't specify any language.
 void imports(PageDefinition pgdef)
          Imports the component definitions from the specified definition.
 void init(Page page, boolean evalHeaders)
          Initializes a page after execution is activated.
 void initXelContext(Page page)
          Initializes XEL context for the specified page.
 void setCacheable(java.lang.Boolean cacheable)
          Sets if the client can cache the rendered result.
 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 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()
           
 
Methods inherited from class org.zkoss.zk.ui.metainfo.NodeInfo
appendChild, appendChild, appendChild, appendChild, getChildren, removeChild, removeChild, removeChild, removeChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageDefinition

public PageDefinition(LanguageDefinition langdef,
                      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.

PageDefinition

public PageDefinition(LanguageDefinition langdef,
                      java.lang.String id,
                      java.lang.String title,
                      java.lang.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. See setId(java.lang.String).
title - the title. See setTitle(java.lang.String).
style - the CSS style. See setStyle(java.lang.String).
Method Detail

getLanguageDefinition

public LanguageDefinition getLanguageDefinition()
Returns the language definition that this page is default to be.


getParent

public NodeInfo getParent()
Returns the parent (always null).

Specified by:
getParent in class NodeInfo

getLocator

public org.zkoss.util.resource.Locator getLocator()
Returns the locator associated with this page definition.


getZScriptLanguage

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

Default: Java.


setZScriptLanguage

public void setZScriptLanguage(java.lang.String zslang)
Sets the default scripting language which is assumed when a zscript element doesn't specify any language.

Parameters:
zslang - the default scripting language.

getId

public java.lang.String getId()
Returns the identitifer 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

public void setId(java.lang.String id)
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 unquie in the same request.

getTitle

public 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.

Note: the returned value might contain EL expressions.


setTitle

public 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.

Parameters:
title - the title. If empty, null is assumed.

getStyle

public 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.

Note: the returned value might contain EL expressions.


setStyle

public 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.

Parameters:
style - the CSS style. If empty, null is assumed.

getRequestPath

public java.lang.String getRequestPath()
Returns the request path of this page definition, or "" if not available.

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


setRequestPath

public void setRequestPath(java.lang.String path)
Sets the request path of this page definition.


imports

public void imports(PageDefinition pgdef)
Imports the component definitions from the specified definition.


addInitiatorInfo

public void addInitiatorInfo(InitiatorInfo init)
Adds a defintion of Initiator.


doInit

public java.util.List doInit(Page page)
Returns a list of all Initiator and invokes its Initiator.doInit(org.zkoss.zk.ui.Page, java.lang.Object[]) before returning. It never returns null.


addVariableResolverInfo

public void addVariableResolverInfo(VariableResolverInfo resolver)
Adds a defintion of VariableResolver.


addXelMethod

public void addXelMethod(java.lang.String prefix,
                         java.lang.String name,
                         org.zkoss.xel.Function func)
Adds a XEL method.

Parameters:
prefix - the prefix of the method name
name - the method name. The final name is "prefix:name"
func - the function.
Since:
3.0.0

initXelContext

public void initXelContext(Page page)
Initializes XEL context for the specified page.

Parameters:
page - the page to initialize the context. It cannot be null.

addHeaderInfo

public void addHeaderInfo(HeaderInfo header)
Adds a header definition (HeaderInfo).


getHeaders

public java.lang.String getHeaders(Page page)
Converts the header definitions (added by addHeaderInfo(org.zkoss.zk.ui.metainfo.HeaderInfo)) to HTML tags.


getContentType

public java.lang.String getContentType(Page page)
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

public void setContentType(java.lang.String contentType)
Sets the content type.

Default: null (use the device default).

Parameters:
contentType - the content type. It may coontain EL expressions.
Since:
3.0.0

getDocType

public java.lang.String getDocType(Page page)
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

public void setDocType(java.lang.String docType)
Sets the doc type (<!DOCTYPE>).

Default: null (use the device default).

Parameters:
docType - the doc type. It may coontain EL expressions.
Since:
3.0.0

getFirstLine

public java.lang.String getFirstLine(Page page)
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

public void setFirstLine(java.lang.String firstLine)
Sets the first line to be generated to the output.

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

Since:
3.0.0

getCacheable

public java.lang.Boolean getCacheable()
Returns if the client can cache the rendered result, or null to use the device default.

Since:
3.0.0

setCacheable

public void setCacheable(java.lang.Boolean cacheable)
Sets if the client can cache the rendered result.

Default: null (use the device default).

Since:
3.0.0

setRootAttribute

public void setRootAttribute(java.lang.String name,
                             java.lang.String value)
Adds a root attribute. The previous attributee of the same will be replaced.

Parameters:
value - the value. If null, the attribute is removed. It can be an EL expression.
Since:
3.0.0

getRootAttributes

public 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. For HTML, the root element is the HTML element.

Since:
3.0.0

getComponentDefinitionMap

public ComponentDefinitionMap getComponentDefinitionMap()
Returns the map of component definition (never null).


addComponentDefinition

public void addComponentDefinition(ComponentDefinition compdef)
Adds a component definition belonging to this page definition only.

It is the same as calling ComponentDefinitionMap.add(org.zkoss.zk.ui.metainfo.ComponentDefinition) against getComponentDefinitionMap()


getComponentDefinition

public ComponentDefinition getComponentDefinition(java.lang.String name,
                                                  boolean recur)
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:
recur - whether to look up the component from getLanguageDefinition()

getComponentDefinition

public ComponentDefinition getComponentDefinition(java.lang.Class cls,
                                                  boolean recur)
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:
recur - whether to look up the component from getLanguageDefinition()

addTaglib

public void addTaglib(org.zkoss.xel.taglib.Taglib taglib)
Adds a tag lib.


addExpressionImport

public void addExpressionImport(java.lang.String nm,
                                java.lang.Class cls)
Adds an imported class to the expression factory.

Since:
3.0.0

setExpressionFactoryClass

public void setExpressionFactoryClass(java.lang.Class expfcls)
Sets the implementation of the expression factory that shall be used by this page.

Default: null (use the default).

Parameters:
expfcls - the implemtation class, or null to use the default. Note: expfcls must implement ExpressionFactory. If null is specified, the class defined in Configuration.getExpressionFactoryClass()
Since:
3.0.0

getExpressionFactoryClass

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

Since:
3.0.0
See Also:
setExpressionFactoryClass(java.lang.Class)

getEvaluator

public Evaluator getEvaluator()
Returns the evaluator based on this page definition (never null).

Since:
3.0.0

getEvaluatorRef

public EvaluatorRef getEvaluatorRef()
Returns the evaluator reference (never null).

Specified by:
getEvaluatorRef in class NodeInfo
Since:
3.0.0

getFunctionMapper

public org.zkoss.xel.FunctionMapper getFunctionMapper()
Returns the function mapper, or null if no mappter at all.


init

public void init(Page page,
                 boolean evalHeaders)
Initializes a page after execution is activated. It setup the identifier and title, and adds it to desktop.


getPageDefinition

public PageDefinition getPageDefinition()
Description copied from class: NodeInfo
Returns the page definition, or null if not available.

Specified by:
getPageDefinition in class NodeInfo

toString

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


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.