【发布时间】:2014-10-08 22:53:21
【问题描述】:
当使用<p:ajax event="rowDblselect" immediate="true" process="@this" oncomplete="PF('tgelPrintForm').show();" update=":form:modalDialog" /> 两次单击数据表行时,我有p:dataTable 并显示p:dialog。在对话框中,我有一个按钮可以更改选定数据表行单元格之一的状态。问题是我不知道如何使用新值更新该单元格。我想我需要一些 primefaces 配置,primefaces 会自动更新,但由于我对 JSF 和 Primefaces 很陌生,所以解决这个问题对我来说是个问题。这是我下面的代码。
数据表:
<p:dataTable styleClass="myDataGrid" id="tbl2" var="domesticTransactions" value="#{domesticTransferGridManagedBean.domesticTransactions}"
paginator="true" rows="15" rowKey="#{domesticTransactions.id}" scrollable="true" scrollHeight="280"
paginatorPosition="bottom"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
selection="#{domesticTransferGridManagedBean.selectedDomesticTransfer}" selectionMode="single">
<p:ajax event="rowDblselect" immediate="true" process="@this" oncomplete="PF('tgelPrintForm').show();" update=":form:modalDialog" />
对话:
<p:dialog dynamic="true" id="modalDialog" appendToBody="@{body}" widgetVar="tgelPrintForm"
modal="true" height="400" width="750px" resizable="false" closeOnEscape="true"> <c:choose>
<c:when test="#{domesticTransferGridManagedBean.selectedDomesticTransfer.status eq 'WAITING_FOR_FIRST_SIGNER_SIGN'}">
<p:commandButton actionListener="#{domesticTransferGridManagedBean.addFirstSignerSignToDomesticTransaction}"
id="domesticTransferFirstSignerSign"
value="#{msg['label.FirstSignerSignature']}"
styleClass="myButton"
process="@this"
update="status"
oncomplete="PF('tgelPrintForm').hide()">
</p:commandButton>
托管 bean 方法:
private DomesticTransfer selectedDomesticTransfer;
public void addFirstSignerSignToDomesticTransaction() {
try {
long domesticTransferId = selectedDomesticTransfer.getId();
assert domesticTransferId > 0;
selectedDomesticTransfer = domesticTransferService.addFirstSignToDomesticTransfer(domesticTransferId);
} catch(Exception e) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, e.getMessage(), null));
}
}
【问题讨论】:
标签: jsf jsf-2 primefaces