[英]Primefaces field update button
我有一個簡單的 primefaces 頁面,用於列出訂單信息
<?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>
我需要一個按鈕來更新整個列表的這個字符串<h:outputText value="#{itemView.getItemInfo(detail.serialNumber)}"/>
。 但是由於它處於雙 foreach 循環中,我該如何管理將此字段分配給按鈕操作?
嘗試在輸出文本中添加一個名為 observe-update 的樣式,例如...
<h:outputText value="#{itemView.getItemInfo(detail.serialNumber)}"
styleClass="observe-update"/>
然后在您的 update="" 按鈕中進行更新...
<p:commandButton update="@(.observe-update)" ...
這是使用觀察者模式的一個巧妙技巧,通過讓 PF 搜索表達式找到所有匹配該樣式的組件並更新它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.