Hibernate saves twice the entity executed within the dialog of the firstfaces

1
When the save button is on the page it works normally and saves the entity but I open a dialog to confirm the data to be saved and hibernate saves twice very strange the method to save out of dialog works correctly but inside it performs two times.

<p:dialog id="dialogconfirmarvenda" appendTo="@(body)" widgetVar="dcv" closable="true" width="1000" maximizable="true" binding="#{vendaMB.dialogconfirmarvenda}" minimizable="true" position="top">
    <p:ajax event="close" listener="#{vendaMB.closeDialog()}" />
    <f:facet name="header"><h:outputText value="CONFIRMAR VENDA" style="font-family: sans-serif"/></f:facet>
    <h:form id="formfinalizarvenda">
        <p:panelGrid id="panelgridconfirmarvenda">
            <p:row>
                <p:column rendered="#{vendaMB.clienteMB.clienteDAO.cliente != null}"><h:outputText value="Cliente" styleClass="text"/></p:column>
                <p:column rendered="#{vendaMB.clienteMB.clienteDAO.cliente != null}"><h:outputText value="#{vendaMB.clienteMB.clienteDAO.cliente.nome}" styleClass="text"/></p:column>
                <p:column><h:outputText value="Pagamento" styleClass="text"/></p:column>
                <p:column><h:outputText value="#{vendaMB.meioPgtoMB.meioPgtoDAO.meiopgto.descricao}" styleClass="text"/></p:column>
                <p:column><h:outputText value="Total da Venda" styleClass="text"/></p:column>
                <p:column><h:outputText value="#{vendaMB.totalVenda}" styleClass="text"><f:convertNumber type="currency"/></h:outputText></p:column>
                <p:column>
                    <p:commandButton actionListener="#{vendaMB.finalizarVenda()}" value="Finalizar" oncomplete="PF('dcv').hide()"/>
                </p:column>
            </p:row>
        </p:panelGrid>
        <p:spacer height="10" width="800"/>
        <p:dataTable id="tableitensvenda" value="#{vendaMB.itemvendaAdds}" var="ivadd">
            <p:column headerText="Código"><h:outputText value="#{ivadd.itemvenda.produto.codigo}"/></p:column>
            <p:column headerText="Produto"><h:outputText value="#{ivadd.itemvenda.produto.descricao}"/></p:column>
            <p:column headerText="Preço">
                <h:outputText value="#{ivadd.itemvenda.valor}">
                    <f:convertNumber type="currency"/>
                </h:outputText>
            </p:column>
            <p:column headerText="Qtd"><h:outputText value="#{ivadd.itemvenda.quantidade}"/></p:column>
            <p:column headerText="Total"><h:outputText value="#{ivadd.total}"><f:convertNumber type="currency"/></h:outputText></p:column>
        </p:dataTable>
    </h:form>
</p:dialog>

This is the dialog for displaying the data for confirmation. The link that opens the dialog:

<p:commandLink value="venda" title="Confirmar Venda" oncomplete="PF('dcv').show()" actionListener="#{vendaMB.confirmarVenda}" />

public void confirmarVenda() {
    for (Meiopgto meiopgto : meioPgtoMB.getMeiopgtos()) {
        if (meiopgto.getIdmeiopgto().equals(idmeiopgto)) {
            meioPgtoMB.getMeioPgtoDAO().setMeiopgto(meiopgto);
            break;
        }
    }
    RequestContext.getCurrentInstance().update(Arrays.asList("formvenda", "dialogconfirmarvenda"));
}
    
asked by anonymous 17.01.2015 / 17:14

1 answer

1

I solved the problem by removing the binding="# {sellMB.dialogconfirmend sale}" from Dialog

    
25.01.2015 / 14:42