Reputation: 121
I have a simple primefaces page for listing orders information
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<h:head>
</h:head>
<h:body>
<h3><h:outputText value="#{orderView.date.month}, #{orderView.date.dayOfMonth} #{orderView.date.year}"/></h3>
<h:form>
<c:forEach items="#{orderView.orders}" var="order">
<p:growl id="msgs" showDetail="true" skipDetailIfEqualsSummary="true"/>
<p:panel id="basic" header="Order ##{order.id} for #{order.customerName} from #{order.customerAddress}, #{order.date}"
footer="Total: #{order.totalPrice}" style="margin-bottom:20px">
<h:panelGrid columns="2" cellpadding="10">
<c:forEach items="#{order.orderDetails}" var="detail">
<h:outputText value="#{detail.rowId}. #{detail.serialNumber} #{detail.amount} pcs"/>
<hr/>
<h:outputText value="#{itemView.getItemInfo(detail.serialNumber)}"/>
<hr/>
</c:forEach>
</h:panelGrid>
</p:panel>
</c:forEach>
</h:form>
</h:body>
</html>
And I need a button which would update this string <h:outputText value="#{itemView.getItemInfo(detail.serialNumber)}"/>
for the whole list. But since it's in a double foreach cycle how do I manage assign this field to button action?
Upvotes: 1
Views: 147
Reputation: 12019
Try adding a style called observe-update to your output text like...
<h:outputText value="#{itemView.getItemInfo(detail.serialNumber)}"
styleClass="observe-update"/>
Then in your button for your update="" to update do this...
<p:commandButton update="@(.observe-update)" ...
Its a clever trick using the Observer pattern by having PF Search Expression find all components that match that style and update them.
Upvotes: 3