I am creating one to edit a database client. It loads the data with the values of the attribute of the last object, but in less than a second it closes again. What to do?
XHTML (customer datatable) code:
<p:dataTable id="clientes" value="#{clienteMB.clientes}" var="item">
<p:column headerText="CNPJ" style="text-align: center">
<h:outputLabel value="#{item.cnpj}" />
</p:column>
<p:column headerText="Razão Social" style="text-align: center">
<h:outputLabel value="#{item.razao_social}" />
</p:column>
<p:column style="width:40px;text-align: center">
<p:commandButton icon="ui-icon-pencil" onclick="PF('new_cliente').show()"
title="Editar" update=":new_cliente">
<f:setPropertyActionListener value="#{item}" target="#{clienteMB.cliente_aux}"/>
<ui:param name="var_cnpj" value="#{clienteMB.cliente_aux.cnpj}"/>
<ui:param name="var_razao" value="#{clienteMB.cliente_aux.razao_social}"/>
</p:commandButton>
</p:column>
<p:column style="width:40px;text-align: center">
<p:commandButton icon="ui-icon-trash" action="#{clienteMB.deletaCliente(item.cnpj)}"/>
</p:column>
<p:column style="width:40px;text-align: center">
<p:commandButton icon="ui-icon-bookmark" action="#"/>
</p:column>
</p:dataTable>
XHTML code (dialog changes client):
<p:dialog id="new_cliente" header="Dados do Usuário" widgetVar="new_cliente" width="400" modal="false" resizable="false">
<h:panelGrid columns="2">
<h:outputLabel value="CNPJ: " />
<h:inputText value="#{var_cnpj}" />
<h:outputLabel value="Razão Social: " />
<h:inputText value="#{var_razao}" />
</h:panelGrid>
</p:dialog>