My page consists of several areas which are created by iterating over a list of items using <ui:repeat>
. Imagine this simplified example:
<h:form id="form">
<ui:repeat id="repeatContainer" var="item" value="#{testBean.items}" varStatus="status">
<h:outputText value="#{item.title}: "/>
<!-- I want to re-render only a single one of these fields -->
<h:outputText id="valueContainer" value="#{item.value}"/><br/>
</ui:repeat>
</h:form>
Now, I want to re-render (only) the valueContainer
of a specific element within this list using AJAX (say, the element with index 1). I have already tried all of these combinations without any luck:
<!-- Works, but renders all items: -->
<f:ajax render=":form"/>
<!-- This is what I actually want to achieve (does not work, comp. not found): -->
<f:ajax render=":form:repeatContainer:1:valueContainer"/>
<!-- Does not work (component not found): -->
<f:ajax render=":form:repeatContainer"/>
<!-- Does not work (component not found): -->
<f:ajax render=":form:repeatContainer:1"/>
<!-- Does not work (component not found): -->
<f:ajax render=":form:1"/>
<!-- Does not work (component not found): -->
<f:ajax render=":form:1:valueContainer"/>
<!-- Does not work (no error message, but does nothing): -->
<f:ajax render=":form:repeatContainer:valueContainer"/>
My requirements include:
- I need to identify the component to re-render with an absolute identifier path, because the button that triggers the update is somewhere completely different in the component tree.
- Re-rendering the entire page or
form (using
@all
/@form
) is useless to me, because that kind of puts into question why I am using JSF/AJAX at all... - I need to achieve the same thing with PrimeFaces
<p:dataGrid>
cells (i.e. update only a specific sub-component of a specific cell), but I assume that this reduces to the same problem.
I guess there must be an easy solution to this that I am currently overlooking?!