0
votes

I have p:dataTable and display p:dialog when datatable row is clicked twice using <p:ajax event="rowDblselect" immediate="true" process="@this" oncomplete="PF('tgelPrintForm').show();" update=":form:modalDialog" />. In the dialog I have a buttion that chages state one of the selected datatable rows cell. Problem is that I don't know how to update that cell with the new value. I think I need some primefaces configuration and primefaces will update that automatically but since I am very new to JSF and Primefaces it is problem for me to solve that issue. This is my code below.

datatable:

<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" />

dialog:

 <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>

managed bean method:

    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));
    }
}
2

2 Answers

1
votes

Your dialog should update the table tbl2 containing the selected entry as well:

<p:commandButton actionListener="#{domesticTransferGridManagedBean.addFirstSignerSignToDomesticTransaction}" 
                 id="domesticTransferFirstSignerSign"
                 value="#{msg['label.FirstSignerSignature']}" 
                 styleClass="myButton"
                 process="@this"
                 update="status tbl2"
                 oncomplete="PF('tgelPrintForm').hide()">
1
votes

You just need to update your datatable, passing the datatable id to the update param in your command button.

<p:commandButton actionListener="#{domesticTransferGridManagedBean.addFirstSignerSignToDomesticTransaction}" 
                                       id="domesticTransferFirstSignerSign"
                                       value="#{msg['label.FirstSignerSignature']}" 
                                       styleClass="myButton"
                                       process="@this"
                                       update="status tbl2"
                                       oncomplete="PF('tgelPrintForm').hide()">
</p:commandButton>

Depending on the location of the table and the dialog, you may need to pass the absolute id of the datatable:

update="status :tbl2" or update="status form:tbl2" etc.