public class RenderUtils extends Object
Modifier and Type | Method and Description |
---|---|
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.
|
public static void encodeRecursive(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws IOException
IOException
public static String getFormId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
context
- the faces context objectcomponent
- UIComponent whose container form id is to be retuirnedpublic static String getRelativeId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent from, String scopedId)
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.
context
- from
- the component to search relative toscopedId
- the relative id path from the 'from' component to the
component to findComponentUtils.findRelativeComponent(javax.faces.component.UIComponent, java.lang.String)
,
UIComponent.findComponent(java.lang.String)
Copyright © 2001-2016 The Apache Software Foundation. All Rights Reserved.