Primefaces的DataTable火灾更新三次

Primefaces的DataTable火灾更新三次

问题描述:

在按钮下面示出与update="testTable"Bean.getSensors火灾呼叫倍的代码,但与update="@form"火灾只有一个按钮。为什么?Primefaces的DataTable火灾更新三次

<h:form id="form4" prependId="true"> 
    <p:commandButton value="id" update="testTable" process="@none"/> 
    <p:commandButton value="@form" update="@form" process="@none"/> 

    <p:dataTable id="testTable" value="#{bean.sensors}" 
        var="sensor" 
        rowStyleClass="#{sensor.alarm ? 'alarm' : null}"> 
     <p:column headerText="Name" style="min-width: 100px; width: 100px;"> 
      <h:outputText value="#{sensor.name}"/> 
     </p:column> 
     <p:column headerText="Value" style="min-width: 100px; width: 100px;"> 
      <h:outputText value="#{sensor.value}"/> 
     </p:column> 
    </p:dataTable> 
</h:form> 

谢谢大家!

这是正常现象。 JSF和Primefaces需要多次调用它。 如果您有任何性能问题,请使用延迟加载

public List<Sensor> getSensors(){ 
    if(sensors == null){ 
     sensors = ejb.getSensors(); 
    } 
    return sensors; 
}