Class WTemplate

    • Constructor Detail

      • WTemplate

        public WTemplate()
        Construct WTemplate.
      • WTemplate

        public WTemplate​(String templateName)
        Parameters:
        templateName - the template file name
      • WTemplate

        public WTemplate​(String templateName,
                         String engineName)
        Parameters:
        templateName - the template file name and path
        engineName - the template engine
    • Method Detail

      • setTemplateName

        public void setTemplateName​(String templateName)
        Parameters:
        templateName - the template file name and path
      • getTemplateName

        public String getTemplateName()
        Returns:
        the template file name and path
      • setInlineTemplate

        public void setInlineTemplate​(String inlineTemplate)
        Parameters:
        inlineTemplate - the inline template
      • getInlineTemplate

        public String getInlineTemplate()
        Returns:
        the inline template
      • addTaggedComponent

        public void addTaggedComponent​(String tag,
                                       WComponent component)
        Add a tagged component to be included in the template. The component will be rendered in place of the corresponding tag in the template.
        Parameters:
        tag - the tag for this component in the template
        component - the component to add
      • removeTaggedComponent

        public void removeTaggedComponent​(WComponent component)
        Remove a tagged component via the component instance.
        Parameters:
        component - the tagged component to remove
      • removeTaggedComponent

        public void removeTaggedComponent​(String tag)
        Remove a tagged component by its tag.
        Parameters:
        tag - the tag of the component to remove
      • removeAllTaggedComponents

        public void removeAllTaggedComponents()
        Remove all tagged components.
      • getTaggedComponents

        public Map<String,​WComponent> getTaggedComponents()
        Returns:
        the tagged components
      • addParameter

        public void addParameter​(String tag,
                                 Object value)
        Add a template parameter.
        Parameters:
        tag - the tag for the template parameter
        value - the value for the template parameter
      • removeParameter

        public void removeParameter​(String tag)
        Remove a template parameter.
        Parameters:
        tag - the tag of the template parameter to remove
      • removeAllParameters

        public void removeAllParameters()
        Remove all template parameters.
      • getParameters

        public Map<String,​Object> getParameters()
        Returns:
        the template parameters
      • setEngineName

        public void setEngineName​(TemplateRendererFactory.TemplateEngine templateEngine)
        Set a predefined template engine. If null then the default engine is used.
        Parameters:
        templateEngine - the provided template engine or null to use the default engine
      • setEngineName

        public void setEngineName​(String engineName)
        Set a template engine. If null then the default engine is used.

        The engine name must be supported by TemplateRendererFactory and correctly configured as per the factory requirements and have the necessary implementation of TemplateRenderer.

        Parameters:
        engineName - the template engine name
      • getEngineName

        public String getEngineName()
        Returns:
        the template engine name
      • addEngineOption

        public void addEngineOption​(String key,
                                    Object value)
        Pass configuration options to the template engine.

        The options are determined by the TemplateRenderer implementation for the template engine.

        The TemplateRenderer implemented is determined by the TemplateRendererFactory.

        Parameters:
        key - the engine option key
        value - the engine option value
      • removeEngineOption

        public void removeEngineOption​(String key)
        Remove a template engine option.
        Parameters:
        key - the engine option to remove
      • removeAllEngineOptions

        public void removeAllEngineOptions()
        Remove all template engine options.
      • getEngineOptions

        public Map<String,​Object> getEngineOptions()
        Returns:
        the engine options
      • getChildCount

        public int getChildCount()
        Specified by:
        getChildCount in interface Container
        Returns:
        the number of child components currently contained within this component.
      • getChildAt

        public WComponent getChildAt​(int index)
        Retrieves a child component by its index.
        Specified by:
        getChildAt in interface Container
        Parameters:
        index - the index of the child component to be retrieved.
        Returns:
        the child component at the given index.
      • getIndexOfChild

        public int getIndexOfChild​(WComponent childComponent)
        Retrieves the index of the given child.
        Specified by:
        getIndexOfChild in interface Container
        Parameters:
        childComponent - the child component to retrieve the index for.
        Returns:
        the index of the given child component, or -1 if the component is not a child of this component.
      • getChildren

        public List<WComponent> getChildren()
        Retrieves a list of this Container's.
        Specified by:
        getChildren in interface Container
        Returns:
        an immutable list of this Container.
      • isNamingContext

        public boolean isNamingContext()
        A naming context is only considered active if an Id name has been set.
        Specified by:
        isNamingContext in interface NamingContextable
        Returns:
        true if active naming context.
      • getComponentModel

        protected WTemplate.TemplateModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class WBeanComponent
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WTemplate.TemplateModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class WBeanComponent
        Returns:
        the model for this component