Mojarra 2.1.
The question is actually about the component finding algorithm.
I have the following UIRepeat
:
<h:form id="frm">
<ui:repeat id="repeater" value="#{bean.values}" var="v">
<h:panelGroup id="pg">
<!-- content -->
<h:selectBooleanCheckbox id="cb" value="#{bean.v}">
<f:ajax event="change" listener="#{bean.listener()}" render=":frm:repeater:pg" />
</h:selectBooleanCheckbox>
<!-- another content -->
</h:panelGroup>
</ui:repeat>
</h:form>
Now consider the method AjaxBehaviorRenderer#getResolvedId:
private static String getResolvedId(UIComponent component, String id) {
UIComponent resolvedComponent = component.findComponent(id);
if (resolvedComponent == null) {
// RELEASE_PENDING i18n
throw new FacesException(
"<f:ajax> contains an unknown id '"
+ id
+ "' - cannot locate it in the context of the component "+component.getId());
}
return resolvedComponent.getClientId();
}
This method is intended to resolve the render attribute value to a component. Now, in the debugger I found that the method is being called with the following parameters in my case:
component = the instance of the HtmlSelectBooleanCheckbox
id = :frm:repeater:pg
Now, the method component.findComponent(id)
returns the component which has clientId
- frm:repeater:0:pg
. But invoking the method as component.findComponent(":frm:repeater:0:pg")
returns null
.
Why? I expected the result would be the same. What did I miss?