Class PageDefinition

  • All Implemented Interfaces:
    NodeInfo

    public class PageDefinition
    extends java.lang.Object
    implements 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 Detail

      • PageDefinition

        public PageDefinition​(LanguageDefinition langdef,
                              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.
    • Method Detail

      • getLanguageDefinition

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

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

        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 unique 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.
      • getViewport

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

        Note: the returned value might contain EL expressions.

        Since:
        6.5.0
      • setViewport

        public 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.
        Parameters:
        viewport - the viewport setting. If empty, "auto" is assumed.
        Since:
        6.5.0
      • getWidgetClass

        public java.lang.String getWidgetClass​(Page page)
        Returns the widget class of the given page, or null if the default is used.
        Since:
        5.0.5
      • setWidgetClass

        public void setWidgetClass​(java.lang.String wgtcls)
        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

        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,
                            java.lang.String[] directives)
        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

        public void imports​(PageDefinition pgdef)
        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

        public void addImportedClass​(java.lang.String clsptn)
                              throws java.lang.ClassNotFoundException
        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:
        java.lang.ClassNotFoundException
        Since:
        6.0.0
      • getImportedClasses

        public java.util.List<java.lang.String> getImportedClasses()
        Returns a readonly list of the imported class names.
        Since:
        6.0.0
      • addXelMethod

        public void addXelMethod​(java.lang.String prefix,
                                 java.lang.String name,
                                 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
      • addResponseHeaderInfo

        public void addResponseHeaderInfo​(ResponseHeaderInfo header)
        Adds a response header.
        Since:
        5.0.2
      • getResponseHeaders

        public java.util.Collection<java.lang.Object[]> getResponseHeaders​(Page page)
        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 of 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).
      • addHeaderInfo

        public void addHeaderInfo​(HeaderInfo header,
                                  boolean before)
        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

        public void addHeaderInfo​(HeaderInfo header)
        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

        public 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). 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(org.zkoss.zk.ui.Page)
      • getAfterHeadTags

        public 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). 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:
        getBeforeHeadTags(org.zkoss.zk.ui.Page)
      • addForwardInfo

        public void addForwardInfo​(ForwardInfo forward)
        Adds a forward definition (ForwardInfo).
      • getForwardURI

        public java.lang.String getForwardURI​(Page page)
        Returns the URI to forward to, or null if not to forward. It evaluates the forward definition (added by 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.
      • 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 contain 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 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

        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
      • getAutomaticTimeout

        public java.lang.Boolean getAutomaticTimeout()
        Returns whether to automatically redirect to the timeout URI.
        Since:
        3.6.3
        See Also:
        setAutomaticTimeout(java.lang.Boolean)
      • 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:
        isComplete()
      • setRootAttribute

        public void setRootAttribute​(java.lang.String name,
                                     java.lang.String value)
        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
      • getComponentDefinitionMap

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

        public void addTaglib​(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 implementation class, or null to use the default. Note: expfcls must implement ExpressionFactory. If null is specified, the class defined in Configuration.getExpressionFactoryClass()
        Throws:
        java.lang.IllegalArgumentException - if expfcls does not implement ExpressionFactory
        Since:
        3.0.0
      • getEvaluator

        public Evaluator getEvaluator()
        Description copied from interface: NodeInfo
        Returns the evaluator.

        All nodes in the same ZUML tree has the same evaluator reference (inherited from the root node, getEvaluatorRef()).

        Specified by:
        getEvaluator in interface NodeInfo
      • addTemplateInfo

        public void addTemplateInfo​(TemplateInfo info)
        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

        public java.util.Map<java.lang.String,​TemplateInfo> getTemplatesInfo()
        Gets templates info map
        Since:
        8.0.0
      • toString

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