Class Renderers


  • public final class Renderers
    extends Object
    Collection of utility methods for the Faces API with respect to working with Renderer.
    Since:
    1.5
    Author:
    Bauke Scholtz
    • Field Detail

      • RENDERER_TYPE_CSS

        public static final String RENDERER_TYPE_CSS
        Renderer type of standard Faces stylesheet component resource.
        See Also:
        Constant Field Values
      • RENDERER_TYPE_JS

        public static final String RENDERER_TYPE_JS
        Renderer type of standard Faces script component resource.
        See Also:
        Constant Field Values
    • Method Detail

      • writeText

        public static void writeText​(ResponseWriter writer,
                                     UIComponent component,
                                     String text,
                                     boolean escape)
                              throws IOException
        Write the given text either HTML-escaped or unescaped. Beware of potential XSS attack holes when user-controlled input is written unescaped!
        Parameters:
        writer - The involved response writer.
        component - The associated UI component, usually the parent component.
        text - The text to be written.
        escape - Whether to HTML-escape the given text or not.
        Throws:
        IOException - When an I/O error occurs.
      • writeAttribute

        public static void writeAttribute​(ResponseWriter writer,
                                          UIComponent component,
                                          String name)
                                   throws IOException
        Write component attribute of the given name, if it's not empty. Both HTML attribute name and component property name defaults to the given component attribute name.
        Parameters:
        writer - The involved response writer.
        component - The associated UI component, usually the parent component.
        name - The component attribute name whose value should be written.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)
      • writeAttribute

        public static void writeAttribute​(ResponseWriter writer,
                                          UIComponent component,
                                          String name,
                                          String html)
                                   throws IOException
        Write component attribute of the given name, if it's not empty, as given HTML attribute name. Component property name defaults to the given component attribute name.
        Parameters:
        writer - The involved response writer.
        component - The associated UI component, usually the parent component.
        name - The component attribute name whose value should be written.
        html - The HTML attribute name to be written.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)
      • writeAttribute

        public static void writeAttribute​(ResponseWriter writer,
                                          UIComponent component,
                                          String name,
                                          String html,
                                          String property)
                                   throws IOException
        Write component attribute of the given name, if it's not empty, as given HTML attribute name associated with given component property name.
        Parameters:
        writer - The involved response writer.
        component - The associated UI component, usually the parent component.
        name - The component attribute name whose value should be written.
        html - The HTML attribute name to be written.
        property - The associated component property name.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)
      • writeAttribute

        public static void writeAttribute​(ResponseWriter writer,
                                          String html,
                                          Object value)
                                   throws IOException
        Write given attribute value, if it's not empty, as given HTML attribute name. Component property name defaults to given HTML attribute name.
        Parameters:
        writer - The involved response writer.
        html - The HTML attribute name to be written.
        value - The HTML attribute value to be written.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)
      • writeAttribute

        public static void writeAttribute​(ResponseWriter writer,
                                          String html,
                                          Object value,
                                          String property)
                                   throws IOException
        Write given attribute value, if it's not empty, as given HTML attribute name associated with given component property name.
        Parameters:
        writer - The involved response writer.
        html - The HTML attribute name to be written.
        value - The HTML attribute value to be written.
        property - The associated component property name.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)
      • writeAttributes

        public static void writeAttributes​(ResponseWriter writer,
                                           UIComponent component,
                                           String... names)
                                    throws IOException
        Write component attributes of the given names, if it's not empty. Both HTML attribute name and component property name defaults to the given component attribute name.
        Parameters:
        writer - The involved response writer.
        component - The associated UI component, usually the parent component.
        names - The names of the attributes to be written.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)
      • writeAttributes

        public static void writeAttributes​(ResponseWriter writer,
                                           UIComponent component,
                                           Map<String,​String> names)
                                    throws IOException
        Write component attributes of the given property-HTML mapping of names, if it's not empty. Map key will be used as component property name and map value will be used as HTML attribute name.
        Parameters:
        writer - The involved response writer.
        component - The associated UI component, usually the parent component.
        names - Mapping of component property-HTML attribute names of the attributes to be written.
        Throws:
        IOException - When an I/O error occurs.
        See Also:
        ResponseWriter.writeAttribute(String, Object, String)