Class AbstractRenderer

java.lang.Object
jakarta.faces.render.Renderer
org.apache.struts.faces.renderer.AbstractRenderer
Direct Known Subclasses:
BaseRenderer, CommandLinkRenderer, ErrorsRenderer, FormRenderer, HtmlRenderer, JavascriptValidatorRenderer, LoadMessagesRenderer, StylesheetRenderer, WriteRenderer

public abstract class AbstractRenderer extends Renderer
Abstract base class for concrete implementations of jakarta.faces.render.Renderer for the Struts-Faces Integration Library.
Version:
$Rev$ $Date$
  • Constructor Details

    • AbstractRenderer

      public AbstractRenderer()
  • Method Details

    • decode

      public void decode(FacesContext context, UIComponent component)
      Decode any new state of the specified UIComponent from the request contained in the specified FacesContext, and store that state on the UIComponent.

      The default implementation calls setSubmittedValue() unless this component has a boolean disabled or readonly attribute that is set to true.

      Overrides:
      decode in class Renderer
      Parameters:
      context - FacesContext for the current request
      component - UIComponent to be decoded
      Throws:
      NullPointerException - if context or component is null
    • encodeBegin

      public void encodeBegin(FacesContext context, UIComponent component) throws IOException
      Render the beginning of the specified UIComponent to the output stream or writer associated with the response we are creating.

      The default implementation calls renderStart() and renderAttributes().

      Overrides:
      encodeBegin in class Renderer
      Parameters:
      context - FacesContext for the current request
      component - UIComponent to be decoded
      Throws:
      NullPointerException - if context or component is null
      IOException - if an input/output error occurs
    • encodeChildren

      public void encodeChildren(FacesContext context, UIComponent component) throws IOException
      Render the children of the specified UIComponent to the output stream or writer associated with the response we are creating.

      The default implementation iterates through the children of this component and renders them.

      Overrides:
      encodeChildren in class Renderer
      Parameters:
      context - FacesContext for the current request
      component - UIComponent to be decoded
      Throws:
      NullPointerException - if context or component is null
      IOException - if an input/output error occurs
    • encodeEnd

      public void encodeEnd(FacesContext context, UIComponent component) throws IOException
      Render the ending of the specified UIComponent to the output stream or writer associated with the response we are creating.

      The default implementation calls renderEnd().

      Overrides:
      encodeEnd in class Renderer
      Parameters:
      context - FacesContext for the current request
      component - UIComponent to be decoded
      Throws:
      NullPointerException - if context or component is null
      IOException - if an input/output error occurs
    • encodeRecursive

      protected void encodeRecursive(FacesContext context, UIComponent component) throws IOException
      Render nested child components by invoking the encode methods on those components, but only when the rendered property is true.
      Throws:
      IOException
    • isDisabled

      protected boolean isDisabled(UIComponent component)
      Return true if the specified component is disabled.
      Parameters:
      component - UIComponent to be checked
    • isReadOnly

      protected boolean isReadOnly(UIComponent component)
      Return true if the specified component is read only.
      Parameters:
      component - UIComponent to be checked
    • renderAttributes

      protected void renderAttributes(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException
      Render the element attributes for the generated markup related to this component. Simple renderers that create a single markup element for this component should override this method and include calls to to writeAttribute() and writeURIAttribute on the specified ResponseWriter.

      The default implementation does nothing.

      Parameters:
      context - FacesContext for the current request
      component - EditableValueHolder component whose submitted value is to be stored
      writer - ResponseWriter to which the element start should be rendered
      Throws:
      IOException - if an input/output error occurs
    • renderEnd

      protected void renderEnd(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException
      Render the element end for the generated markup related to this component. Simple renderers that create a single markup element for this component should override this method and include a call to endElement() on the specified ResponseWriter.

      The default implementation does nothing.

      Parameters:
      context - FacesContext for the current request
      component - EditableValueHolder component whose submitted value is to be stored
      writer - ResponseWriter to which the element start should be rendered
      Throws:
      IOException - if an input/output error occurs
    • renderBoolean

      protected void renderBoolean(FacesContext context, UIComponent component, ResponseWriter writer, String[] names) throws IOException
      Render any boolean attributes on the specified list that have true values on the corresponding attribute of the specified UIComponent.
      Parameters:
      context - FacesContext for the current request
      component - EditableValueHolder component whose submitted value is to be stored
      writer - ResponseWriter to which the element start should be rendered
      names - List of attribute names to be passed through
      Throws:
      IOException - if an input/output error occurs
    • renderPassThrough

      protected void renderPassThrough(FacesContext context, UIComponent component, ResponseWriter writer, String[] names) throws IOException
      Render any attributes on the specified list directly to the specified ResponseWriter for which the specified UIComponent has a non-null attribute value. This method may be used to "pass through" commonly used attribute name/value pairs with a minimum of code.
      Parameters:
      context - FacesContext for the current request
      component - EditableValueHolder component whose submitted value is to be stored
      writer - ResponseWriter to which the element start should be rendered
      names - List of attribute names to be passed through
      Throws:
      IOException - if an input/output error occurs
    • renderStart

      protected void renderStart(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException
      Render the element start for the generated markup related to this component. Simple renderers that create a single markup element for this component should override this method and include a call to startElement() on the specified ResponseWriter.

      The default implementation does nothing.

      Parameters:
      context - FacesContext for the current request
      component - EditableValueHolder component whose submitted value is to be stored
      writer - ResponseWriter to which the element start should be rendered
      Throws:
      IOException - if an input/output error occurs
    • setSubmittedValue

      protected void setSubmittedValue(FacesContext context, UIComponent component)
      If a submitted value was included on this request, store it in the component as appropriate.

      The default implementation determines whether this component implements EditableValueHolder. If so, it checks for a request parameter with the same name as the clientId of this UIComponent. If there is such a parameter, its value is passed (as a String) to the setSubmittedValue() method on the EditableValueHolder component.

      Parameters:
      context - FacesContext for the current request
      component - EditableValueHolder component whose submitted value is to be stored
    • getAsString

      protected String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException

      Convert the Object representation of this component's value to the corresponding String representation. The default implementation utilizes the getAsString() method of any associated Converter.

      Parameters:
      context - The FacesContext for this request
      component - The UIComponent whose value is being converted
      value - The Object representation to be converted
      Throws:
      ConverterException - if conversion fails
    • isXhtml

      protected boolean isXhtml(UIComponent component)
      Return true if we should render as XHTML.
      Parameters:
      component - The component we are rendering
    • searchComponent

      protected <T extends UIComponent> T searchComponent(Class<T> clazz, UIComponent component)
      Search the give UIComponent in the component-tree.
      Parameters:
      component - The entry-point into component-tree.
      Returns:
      The UIComponent or null if the component is not found.