Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsf 2.0 update specific element inside ui:repeat

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!

like image 905
Niko Avatar asked Jun 29 '26 10:06

Niko


1 Answers

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.

like image 187
Kishor Prakash Avatar answered Jul 01 '26 04:07

Kishor Prakash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!