I'm having problems updating an inner nested h:panelGroup
element using f:ajax
. I have minimized my problem into following example:
<h:form id="someForm">
<h:panelGroup id="wrapper">
<h:panelGroup id="content">
Some Content
</h:panelGroup>
</h:panelGroup>
<h:commandLink
action="#{bean.changeContent()}"
value="Do Something">
<f:ajax render=":someForm:wrapper:content"/>
</h:commandLink>
</h:form>
When i try to open the page, the findComponent
method throws an IllegalArgumentException
with no further information:
Severe: Error Rendering View[/view/group/invitation/testCase.xhtml]
java.lang.IllegalArgumentException: wrapper
at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:655)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.getResolvedId(AjaxBehaviorRenderer.java:302)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.appendIds(AjaxBehaviorRenderer.java:292)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.buildAjaxCommand(AjaxBehaviorRenderer.java:225)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.getScript(AjaxBehaviorRenderer.java:89)
...
I looked into the implementation and found following section that was causing the Exception:
...
result = findComponent(base, segments[i], (i == 0));
// the first element of the expression may match base.id
// (vs. a child if of base)
if (i == 0 && result == null && segments[i].equals(base.getId())) {
result = base;
}
if (result != null && (!(result instanceof NamingContainer)) && length > 0) {
throw new IllegalArgumentException(segments[i]);
}
...
I debugged the program, the component is found (by the first line of the code above), so my only conclusion is that h:panelGroup
is not an instance of NamingContainer
, but after reading this post and checking the generated HTML for other examples my understanding was that a h:panelGroup
IS a naming container. However, when i remove the wrapper and tell the ajax element to update the content
panelGroup
directly, no exception is thrown. I probably don't fully understand the method that JSF uses to search through the elements, I'd appreciate it if someone could explain to me why this tiny example behaves this way.
I am using Mojarra 2.2.0 on GlassFish 4.0