![](/img/trans.png)
[英]PrimeFaces commandButton in confirmDialog not calling backing bean
[英]Displaying Primefaces confirmDialog from Backing Bean
我有一個 Primefaces 數據表,當用戶單擊一行時,我會在表單中顯示要編輯的數據。 如果用戶更改表單中的數據並單擊任何其他行,即如果有臟數據,我需要彈出一個 confirmDialog 以顯示用戶是否要保存數據/丟棄數據。 當我嘗試從支持 bean 執行它時,confirmDialog 不顯示。 任何幫助表示贊賞!
我已經實現如下:
<p:dataTable id="tsTableId" value="#{transactionSetBean.studentList}" var="tsRow"
selectionMode="single" selection="#{transactionSetBean.selectedEditRec}" rowKey="#{tsRow.id}" scrollRows="10">
<p:ajax event="rowSelect" listener="#{transactionSetBean.onRowSelect}" update=":transactionSetsForm:tsEntryFrmId">
</p:ajax>
..
</p:dataTable>
<p:confirmDialog widgetVar="dataChangeDlg" message="Save changes Or Cancel">
<p:commandButton value="Save Changes" oncomplete="PF('dataChangeDlg').hide();"
update=":transactionSetsForm:messages :transactionSetsForm:tsEntryFrmId"
action="#{transactionSetBean.updateRecord}" />
<p:commandButton value="Cancel" onclick="PF('dataChangeDlg').hide();"
</p:confirmDialog>
public void onRowSelect(SelectEvent event)
{
String actionName = ON_ROW_SELECT;
try
{
Student selectedObj = (Student)event.getObject();
if (selectedObj != null)
{
selectedEditRec = selectedObj;
}
// if data is changed then show the dataChange dialog
if (isDataChanged())
{
setShowDataChangedDialog(true);
RequestContext context = RequestContext.getCurrentInstance();
// execute javascript and show dialog
context.execute("PF('dataChangeDlg').show();");
}
}
catch (Exception e)
{
handleException(e);
}
}
RequestContext.getCurrentInstance().execute("PF('dataChangeDlg').show();");
<p:ajax event="rowSelect" listener="#{transactionSetBean.onRowSelect}" update=":transactionSetsForm:tsEntryFrmId">
為我工作。 一定有另一個錯誤。 也許 isDataChanged 是錯誤的,更新中的組件 ID 錯誤等等。
PrimeFaces >= 6.2
PrimeFaces.current().executeScript("PF('dataChangeDlg').show()");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.