org.richfaces.renderkit.util

## Class RendererUtils

- java.lang.Object
- - org.richfaces.renderkit.util.RendererUtils

-     public class RendererUtils
      extends Object

  Util class for common render operations - render pass-through html attributes, iterate over child components etc.
  Version:
    $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
  Author:
    asmirnov@exadel.com (latest modification by $Author: alexsmirnov $)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DUMMY_FORM_ID`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RendererUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `attributeValue(String name, Object value)` Convert attribute value to proper object.
    `String` | `clientId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)` Simplified version of `encodeId(FacesContext, UIComponent)`
    `String` | `correctForIdReference(String forAttr, javax.faces.component.UIComponent component)` If target component contains generated id and for doesn't, correct for id
    `Map<String,Object>` | `createParametersMap(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)`
    `Object` | `createParameterValue(javax.faces.component.UIParameter parameter)` Returns value of the parameter.
    `void` | `encodeAttribute(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object property, String attributeName)`
    `void` | `encodeAttribute(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String attribute)`
    `void` | `encodeAttributes(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String attrs)` Encode attributes given by comma-separated string list.
    `void` | `encodeAttributesFromArray(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String[] attrs)`
    `void` | `encodeBeginForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, String clientId)`
    `void` | `encodeBeginFormIfNessesary(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)`
    `void` | `encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)`
    `void` | `encodeCustomId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)` Encode id attribute with clientId component property.
    `void` | `encodeEndForm(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer)`
    `void` | `encodeEndFormIfNessesary(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)`
    `void` | `encodeId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)` Encode id attribute with clientId component property
    `void` | `encodeId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String attribute)` Encode clientId to custom attribute ( for example, to control name )
    `void` | `encodePassThru(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String defaultHtmlEvent)` Encode common pass-thru html attributes.
    `void` | `encodePassThruAttribute(javax.faces.context.FacesContext context, Map<String,Object> attributes, javax.faces.context.ResponseWriter writer, String attribute)` Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.
    `void` | `encodePassThruWithExclusions(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String exclusions, String defaultHtmlEvent)` Encode pass-through attributes except specified ones
    `void` | `encodePassThruWithExclusionsArray(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String[] exclusions, String defaultHtmlEvent)`
    `String` | `encodePctOrPx(String value)` formats given value to
    `String` | `encodePx(String value)`
    `javax.faces.component.UIComponent` | `findComponentFor(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String id)` Deprecated.
    `javax.faces.component.UIComponent` | `findComponentFor(javax.faces.component.UIComponent component, String id)` A modified JSF alghoritm for looking up components.
    `String` | `getActionUrl(javax.faces.context.FacesContext facesContext)`
    `protected Object` | `getComponentAttributeName(Object key)` Convert HTML attribute name to component property name.
    `static RendererUtils` | `getInstance()` Use this method to get singleton instance of RendererUtils
    `javax.faces.component.UIComponent` | `getNestingForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)` Deprecated.
    `javax.faces.component.UIComponent` | `getNestingForm(javax.faces.component.UIComponent component)` Find nested form for given component Deprecated: use `getNestingForm(UIComponent)` instead
    `javax.faces.component.UIComponent` | `getSubmittedForm(javax.faces.context.FacesContext facesContext)` Find submitted form for given context
    `boolean` | `hasExplicitId(javax.faces.component.UIComponent component)`
    `boolean` | `isBooleanAttribute(javax.faces.component.UIComponent component, String name)` Get boolean value of logical attribute
    `boolean` | `isEmpty(Object o)` Checks if the argument passed in is empty or not.
    `boolean` | `isForm(javax.faces.component.UIComponent component)` Detects whether given component is form
    `boolean` | `isFormSubmitted(javax.faces.context.FacesContext context, javax.faces.component.UIForm form)` Determines whenever given form has been submitted
    `void` | `writeScript(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object script)` Write JavaScript with start/end elements and type.
    `static void` | `writeState(javax.faces.context.FacesContext context)` Write state saving markers to context, include MyFaces view sequence.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DUMMY_FORM_ID

          public static final String DUMMY_FORM_ID

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RendererUtils

          protected RendererUtils()

  - ### Method Detail

    - #### getInstance

          public static RendererUtils getInstance()

      Use this method to get singleton instance of RendererUtils
      Returns:
        singleton instance

    - #### encodeId

          public void encodeId(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component)
                        throws IOException

      Encode id attribute with clientId component property
      Parameters:
        `context` -
        `component` -
      Throws:
        `IOException`

    - #### encodeId

          public void encodeId(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component,
                      String attribute)
                        throws IOException

      Encode clientId to custom attribute ( for example, to control name )
      Parameters:
        `context` -
        `component` -
        `attribute` -
      Throws:
        `IOException`

    - #### encodeCustomId

          public void encodeCustomId(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component)
                              throws IOException

      Encode id attribute with clientId component property. Encoded only if id not auto generated.
      Parameters:
        `context` -
        `component` -
      Throws:
        `IOException`

    - #### createParameterValue

          public Object createParameterValue(javax.faces.component.UIParameter parameter)

      Returns value of the parameter. If parameter is instance of `JavaScriptParameter`, `NoEcape` attribute is applied.
      Parameters:
        `parameter` - instance of `UIParameter`
      Returns:
        `Object` parameter value

    - #### createParametersMap

          public Map<String,Object> createParametersMap(javax.faces.context.FacesContext context,
                                               javax.faces.component.UIComponent component)

    - #### encodePassThru

          public void encodePassThru(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component,
                            String defaultHtmlEvent)
                              throws IOException

      Encode common pass-thru html attributes.
      Parameters:
        `context` -
        `component` -
      Throws:
        `IOException`

    - #### encodePassThruWithExclusions

          public void encodePassThruWithExclusions(javax.faces.context.FacesContext context,
                                          javax.faces.component.UIComponent component,
                                          String exclusions,
                                          String defaultHtmlEvent)
                                            throws IOException

      Encode pass-through attributes except specified ones
      Parameters:
        `context` -
        `component` -
        `exclusions` -
      Throws:
        `IOException`

    - #### encodePassThruWithExclusionsArray

          public void encodePassThruWithExclusionsArray(javax.faces.context.FacesContext context,
                                               javax.faces.component.UIComponent component,
                                               String[] exclusions,
                                               String defaultHtmlEvent)
                                                 throws IOException

      Throws:
        `IOException`

    - #### encodePassThruAttribute

          public void encodePassThruAttribute(javax.faces.context.FacesContext context,
                                     Map<String,Object> attributes,
                                     javax.faces.context.ResponseWriter writer,
                                     String attribute)
                                       throws IOException

      Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.
      Parameters:
        `context` -
        `writer` -
        `attribute` -
      Throws:
        `IOException`

    - #### encodeAttributesFromArray

          public void encodeAttributesFromArray(javax.faces.context.FacesContext context,
                                       javax.faces.component.UIComponent component,
                                       String[] attrs)
                                         throws IOException

      Throws:
        `IOException`

    - #### encodeAttributes

          public void encodeAttributes(javax.faces.context.FacesContext context,
                              javax.faces.component.UIComponent component,
                              String attrs)
                                throws IOException

      Encode attributes given by comma-separated string list.
      Parameters:
        `context` - current JSF context
        `component` - for with render attributes values
        `attrs` - comma separated list of attributes
      Throws:
        `IOException`

    - #### encodeAttribute

          public void encodeAttribute(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component,
                             Object property,
                             String attributeName)
                               throws IOException

      Parameters:
        `context` -
        `component` -
        `property` -
        `attributeName` -
      Throws:
        `IOException`

    - #### encodeAttribute

          public void encodeAttribute(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component,
                             String attribute)
                               throws IOException

      Throws:
        `IOException`

    - #### isEmpty

          public boolean isEmpty(Object o)

      Checks if the argument passed in is empty or not. Object is empty if it is:
      - `null`
      - zero-length string
      - empty collection
      - empty map
      - zero-length array
      Parameters:
        `o` - object to check for emptiness
      Returns:
        `true` if the argument is empty, `false` otherwise
      Since:
        3.3.2

    - #### getComponentAttributeName

          protected Object getComponentAttributeName(Object key)

      Convert HTML attribute name to component property name.
      Parameters:
        `key` -
      Returns:

    - #### attributeValue

          protected Object attributeValue(String name,
                              Object value)

      Convert attribute value to proper object. For known html boolean attributes return name for true value, otherthise - null. For non-boolean attributes return same value.
      Parameters:
        `name` - attribute name.
        `value` -
      Returns:

    - #### isBooleanAttribute

          public boolean isBooleanAttribute(javax.faces.component.UIComponent component,
                                   String name)

      Get boolean value of logical attribute
      Parameters:
        `component` -
        `name` - attribute name
      Returns:
        true if attribute is equals Boolean.TRUE or String "true" , false otherwise.

    - #### encodePx

          public String encodePx(String value)

    - #### encodePctOrPx

          public String encodePctOrPx(String value)

      formats given value to
      Parameters:
        `value` -
      Returns:

    - #### getNestingForm

          public javax.faces.component.UIComponent getNestingForm(javax.faces.component.UIComponent component)

      Find nested form for given component Deprecated: use `getNestingForm(UIComponent)` instead
      Parameters:
        `component` -
      Returns:
        nested `UIForm` component, or `null`

    - #### getNestingForm

          @Deprecated
          public javax.faces.component.UIComponent getNestingForm(javax.faces.context.FacesContext context,
                                                                    javax.faces.component.UIComponent component)

      Deprecated.
      Find nested form for given component
      Parameters:
        `component` -
      Returns:
        nested `UIForm` component, or `null`

    - #### isForm

          public boolean isForm(javax.faces.component.UIComponent component)

      Detects whether given component is form

    - #### getSubmittedForm

          public javax.faces.component.UIComponent getSubmittedForm(javax.faces.context.FacesContext facesContext)

      Find submitted form for given context
      Parameters:
        `facesContext` -
      Returns:
        submitted `UIForm` component, or `null`

    - #### isFormSubmitted

          public boolean isFormSubmitted(javax.faces.context.FacesContext context,
                                javax.faces.component.UIForm form)

      Determines whenever given form has been submitted

    - #### encodeBeginFormIfNessesary

          public void encodeBeginFormIfNessesary(javax.faces.context.FacesContext context,
                                        javax.faces.component.UIComponent component)
                                          throws IOException

      Parameters:
        `context` -
        `component` -
      Throws:
        `IOException`

    - #### encodeBeginForm

          public void encodeBeginForm(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component,
                             javax.faces.context.ResponseWriter writer,
                             String clientId)
                               throws IOException

      Parameters:
        `context` -
        `component` -
        `writer` -
        `clientId` -
      Throws:
        `IOException`

    - #### encodeEndFormIfNessesary

          public void encodeEndFormIfNessesary(javax.faces.context.FacesContext context,
                                      javax.faces.component.UIComponent component)
                                        throws IOException

      Parameters:
        `context` -
        `component` -
      Throws:
        `IOException`

    - #### writeState

          public static void writeState(javax.faces.context.FacesContext context)
                                 throws IOException

      Write state saving markers to context, include MyFaces view sequence.
      Parameters:
        `context` -
      Throws:
        `IOException`

    - #### encodeEndForm

          public void encodeEndForm(javax.faces.context.FacesContext context,
                           javax.faces.context.ResponseWriter writer)
                             throws IOException

      Parameters:
        `context` -
        `writer` -
      Throws:
        `IOException`

    - #### getActionUrl

          public String getActionUrl(javax.faces.context.FacesContext facesContext)

      Parameters:
        `facesContext` -
      Returns:
        String A String representing the action URL

    - #### clientId

          public String clientId(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)

      Simplified version of `encodeId(FacesContext, UIComponent)`
      Parameters:
        `context` -
        `component` -
      Returns:
        client id of current component

    - #### writeScript

          public void writeScript(javax.faces.context.FacesContext context,
                         javax.faces.component.UIComponent component,
                         Object script)
                           throws IOException

      Write JavaScript with start/end elements and type.
      Parameters:
        `context` -
        `component` -
        `script` -
      Throws:
        `IOException`

    - #### correctForIdReference

          public String correctForIdReference(String forAttr,
                                     javax.faces.component.UIComponent component)

      If target component contains generated id and for doesn't, correct for id
      Parameters:
        `forAttr` -
        `component` -

    - #### encodeChildren

          public void encodeChildren(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component)
                              throws IOException

      Throws:
        `IOException`

    - #### hasExplicitId

          public boolean hasExplicitId(javax.faces.component.UIComponent component)

    - #### findComponentFor

          @Deprecated
          public javax.faces.component.UIComponent findComponentFor(javax.faces.context.FacesContext context,
                                                                      javax.faces.component.UIComponent component,
                                                                      String id)

      Deprecated.
      Deprecated, use `findComponentFor(UIComponent, String)`.

    - #### findComponentFor

          public javax.faces.component.UIComponent findComponentFor(javax.faces.component.UIComponent component,
                                                           String id)

      A modified JSF alghoritm for looking up components.

      First try to find the component with given ID in subtree and then lookup in parents' subtrees.

      If no component is found this way, it uses `findUIComponentBelow(UIComponent, String)` applied to root component.

      Parameters:
        `component` -
        `id` -
      Returns:

Copyright © 2014 JBoss by Red Hat. All Rights Reserved.