I have a code that is little bit odd but it goes something like this:
<h:form id="groupsForm">
<ui:repeat value="#{groupsContainer.groups}" var="group">
<p:outptuText value="#{group.name}" />
<p:card id="group">
<ui:repeat value="#{group.users}" var="user">
<p:outputText value="#{user.name}" />
<p:commandButton
value="Delete"
process="@this"
actionListener="#{groupsController.deleteUserFromGroup(group, user)}"
update="group"
/>
</ui:repeat>
</p:card>
</ui:repeat>
</h:form>
Sadly that command button can't find the group in which it is when rendering the page ending with Java error:
org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression "group" referenced from "groupsForm:j_idt42:0:j_idt73:0:j_idt102".
It seams to me that you can't reference a repeated component from another repeat that is in it. I tried to play with the ids and wrap some components in <h:panelGroup/>
but that didn't helped.
Then I realised that I don't need to update the whole <p:card/>
and it should be enough to update only the second <ui:repeat/>
, so I did this:
<h:form id="groupsForm">
<ui:repeat value="#{groupsContainer.groups}" var="group">
<p:outptuText value="#{group.name}" />
<p:card id="group">
<h:panelGroup id="users">
<ui:repeat value="#{group.users}" var="user">
<p:outputText value="#{user.name}" />
<p:commandButton
value="Delete"
process="@this"
actionListener="#{groupsController.deleteUserFromGroup(group, user)}"
update="users"
/>
</ui:repeat>
</h:panelGroup>
</p:card>
</ui:repeat>
</h:form>
but the result was pretty much the same with only different ids:
Cannot find component for expression "users" referenced from "groupsForm:j_idt42:0:j_idt73:0:j_idt102".
So my question is: Can I somehow update repeated component with repeat from inside of the second repeat?