Q:

PrimeFaces dialog keeps the previous value

I use a dataTable to display the some records. The user can add/change records using a dialog named actionsDialog. Before saving the record, a modal dialog, called reasonDialog, is displayed and the user has to enter some reasons for the current operation. In my logic I set the reason to null after the data is saved into database.
The problem appears when I repeat the operation. The reason contains the previous value. I have debugged the code and noticed that this happens because the reason is assigned the local value of the inputTextarea. How can I get rid of the local value? I am using PrimeFaces 3.0, Mojara 2.0.4, Tomcat 7.
My reason dialog facelet is:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui">  
    <p:dialog header="#{label.reason}" widgetVar="reasonDialog"
        showEffect="fade" hideEffect="explode" modal="true" dynamic="true">        
        <h:panelGrid columns="2">
            <p:inputTextarea rows="5" cols="40" autoResize="false"
                value="#{recordsBean.reason}" maxLength="1024" />
            <f:facet name="footer">
                <p:outputPanel layout="block">
                <p:commandButton value="ok" update="genericRecords msgs"
                    action="#{recordsBean.execute}"
                    oncomplete="reasonDialog.hide();actionsDialog.hide()" />
                </p:outputPanel>
            </f:facet>
        </h:panelGrid>
    </p:dialog>
</ui:composition>

The action dialog looks like this:
<p:dialog id="actionsDialog" widgetVar="actionsDialog" dynamic="true"
    resizable="false" height="600" showEffect="fade" hideEffect="fade" modal="true">
<ui:include src="/WEB-INF/flows/genericRecord.xhtml"/>
<f:facet name="footer">  
        <p:outputPanel layout="block">
    <p:commandButton value="save" onclick="reasonDialog.show()" />
    <p:commandButton value="cancel" immediate="true" 
                oncomplete="actionsDialog.hide()" />
    </p:outputPanel>
</f:facet>
</p:dialog>

A:

You need to update/refresh dialog's contents before showing it. Reference its (relative) client ID in the update attribute and move the show() from onclick to oncomplete so that it takes place after the update.
<p:commandButton value="save" update="reasonDialog" oncomplete="reasonDialog.show()" />

Otherwise it will of course still display the old content as it was before it was closed. You're namely by ajax/JS interacting with exactly the same page, not a new page or so.

A:

Try to add ajax="false" attribute in your p:commandButton; See sample
   <p:commandButton value="ok" update="genericRecords msgs"
                action="#{recordsBean.execute}" ajax="false"
                oncomplete="reasonDialog.hide();actionsDialog.hide()" />

