我正在使用primefaces和JSF 2.0。我有一個刪除列的數據表,看起來像這樣。JSF/Primefaces數據表f:setPropertyActionListener設置上一行的屬性
<p:column id="Delete" headerText="Delete">
<p:commandButton icon="delete" onclick="deleteConfirmation.show()" style="align:center">
<f:setPropertyActionListener value="#{item}" target="#{controller.selectedItem}" /> </p:commandButton>
</p:column>
//刪除確認對話框
<p:confirmDialog id="deleteConfirmDialog" message="Are you sure you want to delete?"
header="Delete" severity="alert"
widgetVar="deleteConfirmation">
<p:commandButton id="confirm" value="Yes"
update=":myList" oncomplete="deleteConfirmation.hide()"
actionListener="#{controller.delete}" />
<p:commandButton id="cancel" value="No"
onclick="deleteConfirmation.hide()" type="button" />
</p:confirmDialog>
一切,當我做對數據表除了過濾的偉大工程。在我篩選並單擊刪除後,selectedItem方法將獲取數據表中的前一行(不是過濾結果的一部分)而不是當前行。
未經篩選即不存在此問題。 我爲我的控制器使用ViewScoped作用域。
爲什麼會發生這種情況的任何想法?這似乎是一個基本的東西,應該由數據表支持,所以我假設我在這裏做錯了什麼。感謝您的幫助
@ Daniel-感謝response.But升級到第3.4頁有助於部分。正確的行被刪除,但刪除後數據表不刷新。如果您注意到我正在更新數據表作爲刪除確認的一部分。思考? – Gowtham
是的,它的原因你可能不會從正在被'filteredValue'屬性引用的列表中移除它...(在另一個列表不是空的情況下,從另一個列表中移除該行),奇怪的解決方案?我也這麼認爲... – Daniel
解釋它之後它是有道理的。但我同意你應該總是從value not filteredValue中獲取值,因爲我要回到數據庫來刷新我的數據表,但這並沒有發生。 – Gowtham