org.apache.myfaces.trinidad.render
Class RenderUtils

java.lang.Object
  extended by org.apache.myfaces.trinidad.render.RenderUtils

public class RenderUtils
extends Object

Generic utilities for rendering.


Method Summary
static void encodeRecursive(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encodes a component and all of its children.
static String getFormId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Retrieves id of the form the component is contained in.
static String getRelativeId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent from, String scopedId)
          Given a 'from' component and a relativeId, return the clientId for use at rendering time that will identify the id of the component you are referencing on the client.
static String getRendererClientId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Returns the clientId used by the renderer in place of the clientId used by the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeRecursive

public static void encodeRecursive(javax.faces.context.FacesContext context,
                                   javax.faces.component.UIComponent component)
                            throws IOException
Encodes a component and all of its children.

Throws:
IOException

getFormId

public static String getFormId(javax.faces.context.FacesContext context,
                               javax.faces.component.UIComponent component)
Retrieves id of the form the component is contained in.

Parameters:
context - the faces context object
component - UIComponent whose container form id is to be retuirned
Returns:
String id of the form if one exists in component's hierarchy, otherwise null

getRelativeId

public static String getRelativeId(javax.faces.context.FacesContext context,
                                   javax.faces.component.UIComponent from,
                                   String scopedId)
Given a 'from' component and a relativeId, return the clientId for use at rendering time that will identify the id of the component you are referencing on the client. This is used for attributes like e.g. "for" and "chooseId".

e.g., given this hierarchy
<f:subview id="aaa"> <f:subview id="xxx">
<tr:chooseColor id="cp1" .../>
<f:subview id="yyy">
<tr:inputColor id="sic1" chooseId="::cp1" .../>
</f:subview>
</f:subview> </f:subview>

The 'from' component is the inputColor component. The 'relativeId' is "::cp1". ('::' pops up one naming container) The return value is 'aaa:xxx:cp1' when the clientId of the 'xxx' component is 'aaa:xxx'.

It does not assume that the target component can be located, although it does check. If it can't be found, it returns the correct relativeId anyway.

A relativeId starting with NamingContainer.SEPARATOR_CHAR (that is, ':') will be treated as absolute (after dropping that character). A relativeId with no colons means it is within the same naming container as the 'from' component (this is within the 'from' component if 'from' is a naming container). A relativeId starting with '::' pops out of the 'from' component's naming container. If the 'from' component is a naming container, then '::' will pop out of the 'from' component itself. A relativeId with ':::' pops up two naming containers, etc. ComponentUtils.findRelativeComponent finds and returns the component, whereas this method returns a relativeId that can be used during renderering so the component can be found in javascript on the client.

Parameters:
context -
from - the component to search relative to
scopedId - the relative id path from the 'from' component to the component to find
Returns:
the clientId for the 'relative' component.
See Also:
ComponentUtils.findRelativeComponent(javax.faces.component.UIComponent, java.lang.String), UIComponent.findComponent(java.lang.String)

getRendererClientId

public static String getRendererClientId(javax.faces.context.FacesContext context,
                                         javax.faces.component.UIComponent component)
Returns the clientId used by the renderer in place of the clientId used by the component. Certain renderers render their root element with a clientId that differs from the one used by the component.

Parameters:
context - FacesContent.
component - UIComponent.
Returns:
component clientId if the renderer clientId is null. Otherwise clientId used by renderer.


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.