0
votes

I have a datatable, and at the last column I will have an edit action, it will trigger the dialog box. However, I found the value in the dialog box is not updated. Can anybody to help on this?

My code as below. In fact the bean.currentItem.name and bean.currentItem.age should base on my selection from the table. I check the bean.currentItem is not null and is refer to my selection from preEdit method, but the value never show up in p:dialog.

<p:dataTable ....>
    <p:column...
    <p:column...
    <p:column>
        <f:facet name="header">
            <h:outputLabel value="Update" />
        </f:facet>
            <p:remoteCommand name="preEdit" action="#{bean.preEdit}"
                process="@this" update="@this @form:dlg">
                <f:setPropertyActionListener target="#{bean.currentItem}"
                            value="#{thisItem}" />
            </p:remoteCommand>
            <p:commandLink styleClass="no-decor"
                oncomplete="preEdit();PF('dlg').show();" value="Edit"/>                         
    </p:column>
</p:dataTable>

<p:dialog header="#{lbl.tt_cat_upd}" widgetVar="dlg" id="dlg"
            resizable="false" >
    <h:outputLabel value="#{bean.currentItem.name}" />
    <h:outputLabel value="#{bean.currentItem.age}" />
</p:dialog>
1

1 Answers

0
votes

How about removing your p:remoteCommand and let your p:commandLink do all the work for you?

Assuming you have a h:form surrounding both your dataTable and your dialog

        <p:commandLink action="#{bean.preEdit}" process="@this" update="dlg" styleClass="no-decor" oncomplete="PF('dlg').show()" value="Edit">
            <f:setPropertyActionListener target="#{bean.currentItem}"
                        value="#{thisItem}" />
       </p:commandLink>

If your dataTable is not in the same form with your dialog, you might replace update="dlg" by update=":formIdContainingDialog:dlg"