3
votes

I'm asking how I can achieve updating a specific element of a loop?

e.g.

<h:form>
    <ui:repeat var="element" value="#{bean.elements}" varStatus="status">
         <h:outputtext value="#{element.text}" id="#{element.id}" />
         <p:commandLink update="#{element.id}" >
             <h:outputtext value="UpdateTextField #{element.id}" />
         </p:commandLink>
    </ui:repeat>
</h:form>

I know that status.index doen't work since its view-rendered. Also the "dynamic" index-setting also doen't work since its view-rendered... But how can i achieve that when the button is clicked, it updates (ajax) the outputtext? Is this only possible with c:forEach?

its ViewScoped and the form must be outside of the loop. otherwise i would solve it with update="@form", but here its not possible

thanks for any help!

1
possible duplicate of Address JSF component in ui:repeat - Lester

1 Answers

2
votes

Since both ui:repeat and c:forEach generate different dynamic Component Ids for the elements you can't Guarantee the update an individual Item out of all generated items from outside.

I think best approach for this kind of problem would be placing a h:panelGroup around ui:repeat or c:forEach itself and update the h:panelGroupitself.