简体   繁体   English

如何从Primefaces的dataTable列中获取预编辑的值?

[英]How to get the pre edited value from a dataTable column in Primefaces?

When clicking on the edit button in PrimeFaces I want my listener to get the new value of the column as well as the old one. 在PrimeFaces中单击“编辑”按钮时,我希望我的监听器获得该列的新值以及旧值。 I am currently only getting the new value: 我目前只获得新的价值:

public void onLicenseEdit(RowEditEvent event) {
    selectedItemLicense = (ItemLicense) event.getObject();
}

This is my xhtml: 这是我的xhtml:

<p:dataTable id="licenses" var="license"
    value="#{itemShowView.itemReference.lastVersionItemLicenses}"
    emptyMessage="#{messages['common.emptymessage']}"
    class="itemLicensesTable"
    selection="itemShowView.selectedLicense"
    editable="true">
    <p:ajax event="rowEdit" update="@(.itemLicensesTable)" listener="#{itemShowView.onLicenseEdit}"  />
    <f:facet name="header">

    <p:column headerText="#{messages['license.licensenumber']}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{license.licensePK.licenseNumber}" />
            </f:facet>
            <f:facet name="input">
                <p:inputText value="#{license.licensePK.licenseNumber}" />
            </f:facet>
        </p:cellEditor>
    </p:column>

    ...

    <p:column>
        <p:rowEditor />
    </p:column>

    ...
</p:dataTable>

Please help. 请帮忙。 Thanks in advance. 提前致谢。

Thank you for your comment. 感谢您的评论。 I modified the code using valueChangeListener. 我使用valueChangeListener修改了代码。 This is my solution: 这是我的解决方案:

<f:facet name="input">
    <p:inputText value="#{itemLicense.itemLicensePK.licenseNumber}" valueChangeListener="#{itemShowView.onLicenceChange}"/>
</f:facet>

and the Java code: 和Java代码:

private ItemLicense selectedItemLicenseForModification;

...

public void onLicenceChange() {
    selectedItemLicenseForModification = (ItemLicense) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("itemLicense");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM