【发布时间】:2015-11-20 02:06:49
【问题描述】:
莫哈拉 2.1。
问题实际上是关于组件查找算法的。
我有以下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>
现在考虑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();
}
此方法旨在将渲染属性值解析为组件。现在,在调试器中,我发现在我的情况下使用以下参数调用该方法:
component = the instance of the HtmlSelectBooleanCheckbox
id = :frm:repeater:pg
现在,component.findComponent(id) 方法返回具有clientId - frm:repeater:0:pg 的组件。但是以component.findComponent(":frm:repeater:0:pg") 调用该方法会返回null。
为什么?我预计结果会是一样的。我错过了什么?
【问题讨论】: