我在 primefaces 数据表中有命令链接,其中包含打开对话框的操作。当点击链接时,总是调用 postconstruct。
我的要求是更新对话框,其中包含编辑所需的详细信息。
部分代码片段:
<p:dataTable id="sampleMasterListDataTable" var="sampleEntry"
value="#{sampleMgmtBean.sampleMasterList}" paginator="true" rows="5"
paginatorAlwaysVisible="false"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks}
{NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPage="5" style="width:600px;">
<p:column headerText="Invoice No">
<h:outputText value="#{sampleEntry.invoiceNo}" />
</p:column>
<p:column headerText="Sales Date">
<h:outputText value="#{sampleEntry.date}">
<f:convertDateTime pattern="dd-MM-yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Update">
<p:commandButton id="editSalesLink" value="Edit"
action="#{sampleMgmtBean.pullSalesDetails(sampleEntry)}"
update=":tabView:editDialog" process="@this" ajax="true"
oncomplete="editSalesDialog.show();" />
</p:column>
</p:dataTable>
对话代码:
<p:dialog id="editDialog" header="Update Sales Dialog"
widgetVar="editSalesDialog" resizable="false" height="500" modal="true">
<h:form id="sampleMasterEditForm" prependId="false">
<p:panelGrid columns="8" cellpadding="5" style="width: 650px">
<h:outputLabel for="editInvoiceNo" value="Invoice:" />
<p:inputText value="#{sampleMgmtBean.sampleMaster.invoiceNo}"
id="editInvoiceNo" required="false" label="invoiceNo" />
<h:outputLabel for="editSalesDate" value="Sales Date:" />
<p:calendar id="editSalesDate" mode="popup" styleClass="calendar"
navigator="true" readonly="readonly"
value="#{sampleMgmtBean.sampleMaster.date}" yearRange="1900:2050"
pattern="dd/MM/yyyy HH:mm:ss">
</p:calendar>
</p:panelGrid>
</h:form>
</p:dialog>
Java 代码
@ManagedBean(name="salesMgmtBean")
@ViewScoped
public class SalesMgmtBean implements Serializable {
@PostConstruct
public void init() {
//new objects
}
}