Got some difficulties addressing components inside ui:repeat
iterating over a collection which is a attribute of a composite component like so:
<ui:component>
<cc:interface>
<cc:attribute name="dummyList" />
</cc:interface>
<cc:implementation>
<div id="#{cc.clientId}">
<ui:repeat id="repeat" value="#{cc.attrs.dummyList}" var="d">
<p:outputPanel>
<h:outputText id="repeat-item" value="#{component.clientId} / #{testBean.state}"/>
</p:outputPanel>
</ui:repeat>
</div>
</cc:implementation>
</ui:component>
This does not work:
<p:commandButton value="Increment (component)"
action="#{testBean.incrementState()}"
process="@this"
update="form:testComp:repeat:0:repeat-item"/>
<comb:testComp id="testComp" dummyList="#{testBean.dummyList}"/>
Error: org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression “form:testComp:repeat:0:repeat-item” referenced from “form:incrementBtn”.
Following constellations work without problems:
- Without composite component (e.g. one document or include or taglib)
<p:commandButton id="incrementBtn"
value="Increment"
action="#{testBean.incrementState()}"
process="@this"
update="form:repeat:0:repeat-item"/>
<ui:repeat id="repeat" value="#{testBean.dummyList}" var="d">
<p:outputPanel>
<h:outputText id="repeat-item" value="#{component.clientId} / #{testBean.state}"/>
</p:outputPanel>
</ui:repeat>
- Without using composite component attribute
<ui:component>
<cc:implementation>
<div id="#{cc.clientId}">
<ui:repeat id="repeat" value="#{testBean.dummyList}" var="d">
<p:outputPanel>
<h:outputText id="repeat-item" value="#{component.clientId} / #{testBean.state}"/>
</p:outputPanel>
</ui:repeat>
</div>
</cc:implementation>
</ui:component>
<p:commandButton id="incrementBtn" value="Increment (component)"
action="#{testBean.incrementState()}"
process="@this"
update="form:testComp:repeat:0:repeat-item"/>
<comb:testComp id="testComp"/>
- Placing the button after the cc tag
<comb:testComp id="testComp" dummyList="#{testBean.dummyList}"/>
<p:commandButton id="incrementBtn" value="Increment (component)"
action="#{testBean.incrementState()}"
process="@this"
update="form:testComp:repeat:0:repeat-item"/>
My real use case is to update a specific panel inside a repeat inside a composite component from a button in a dialog. There I get the same error.
While debugging and playing around with different ideas and solutions I stumbled over the behaviour described above.
-
Is that expected behaviour?
-
“When” can I address components with
“form:testComp:repeat:0:repeat-item”
Like: Is there a rule or a expected order of elements?
Note: “form” is the id of an outer form element.
Because interestingly this (without specifying “form:”) also does not work:
<comb:testComp id="testComp" dummyList="#{testBean.dummyList}"/>
<p:commandButton id="incrementBtn" value="Increment (component)"
action="#{testBean.incrementState()}"
process="@this"
update="testComp:repeat:0:repeat-item"/>
Error: org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression “testComp:repeat:0:repeat-item” referenced from “form:incrementBtn”.
stackisfull is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.