我有一個數據表,其中每行有24個小時的輸入字段。在某個時間點,有超過1000個可編輯的輸入字段。我注意到,在ajax調用期間使用p:cellEditor時,primefaces正在提交整個數據表。我怎樣才能避免這種情況? 請在下面找到我所擁有的代碼,並在其中找到對其中每個重要部分的評論。Primefaces cellEditor在ajax中傳遞整個數據表提交
<!-- Fires the cellEdit event to trigger the validations to happen as user tabs out of the input box -->
<p:ajax event="cellEdit" listener="#{renderValidator.onCellEdit}" update=":#{p:component('globalMessages')}" process="@this" />
<p:column id="hour1" styleClass="col-right col-90">
<f:facet name="header">
<h:outputText value="1" escape="false"/>
</f:facet>
<p:cellEditor >
<f:facet name="output">
<h:outputText value="#{row.amount[0]}" escape="false">
<f:convertNumber maxFractionDigits="3" minFractionDigits="3" maxIntegerDigits="5" />
</h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText id="hour1Input" value="#{row.amount[0]}" maxlength="10" size="10" readonly="#{row.readOnly}" onchange='PowerMeter.setPowerMeterChange()'
styleClass="col-right" valueChangeListener="#{row.setDirtyFlag(true)}" >
<!-- formats data the way its displayed -->
<f:convertNumber maxFractionDigits="3" minFractionDigits="3" maxIntegerDigits="5" />
<!-- validates the input value w.r.t a custom validator -->
<f:validator validatorId="hourlyValueValidator" for="hour1Input" />
<!-- javascript restricting user to input alpha numeric characters -->
<pe:keyFilter testFunction="return PowerMeter.isValidMWH(this, c);" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
Durng Ajax調用驗證,我寧願只是通過特定的輸入文本。我嘗試用id'hour1Input'替換@this,但仍然在chrome中,我可以看到整個表正在提交。 – Sabarish 2013-04-24 21:25:37
如何嘗試[懶惰加載](http://www.primefaces.org/showcase/ui/datatableLazy.jsf)?或者,celleditor可以實現您自己的按鈕。那個不是一件容易的事。 – 2013-04-24 21:27:54