- java.lang.Object
-
- org.omnifaces.util.Renderers
-
public final class Renderers extends Object
Collection of utility methods for the Faces API with respect to working withRenderer
.For a full list, check the method summary.
- Since:
- 1.5
- Author:
- Bauke Scholtz
-
-
Field Summary
Fields Modifier and Type Field Description static String
RENDERER_TYPE_CSS
Renderer type of standard Faces stylesheet component resource.static String
RENDERER_TYPE_JS
Renderer type of standard Faces script component resource.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
writeAttribute(ResponseWriter writer, UIComponent component, String name)
Write component attribute of the given name, if it's not empty.static void
writeAttribute(ResponseWriter writer, UIComponent component, String name, String html)
Write component attribute of the given name, if it's not empty, as given HTML attribute name.static void
writeAttribute(ResponseWriter writer, UIComponent component, String name, String html, String property)
Write component attribute of the given name, if it's not empty, as given HTML attribute name associated with given component property name.static void
writeAttribute(ResponseWriter writer, String html, Object value)
Write given attribute value, if it's not empty, as given HTML attribute name.static void
writeAttribute(ResponseWriter writer, String html, Object value, String property)
Write given attribute value, if it's not empty, as given HTML attribute name associated with given component property name.static void
writeAttributes(ResponseWriter writer, UIComponent component, String... names)
Write component attributes of the given names, if it's not empty.static void
writeAttributes(ResponseWriter writer, UIComponent component, Map<String,String> names)
Write component attributes of the given property-HTML mapping of names, if it's not empty.static void
writeIdAttributeIfNecessary(ResponseWriter writer, UIComponent component)
Write ID of component if necessary.static void
writeText(ResponseWriter writer, UIComponent component, String text, boolean escape)
Write the given text either HTML-escaped or unescaped.
-
-
-
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)
-
writeIdAttributeIfNecessary
public static void writeIdAttributeIfNecessary(ResponseWriter writer, UIComponent component) throws IOException
Write ID of component if necessary. That is, when it's explicitly set or the component has client behaviors.- Parameters:
writer
- The involved response writer.component
- The associated UI component.- Throws:
IOException
- When an I/O error occurs.- Since:
- 2.5
- See Also:
ResponseWriter.writeAttribute(String, Object, String)
-
-