Saudações…
Pessoal to com um problema que para poder descrever fiz um doc no google
https://docs.google.com/document/pub?id=1JUt9kT7cNzAP_XD80IYac8EbuAsvJrYAZ5UZOp8Rd2U
Se vc puderem me dar uma mão agradeço
Aqui o código sobre o meu problema
<h:form id="frmTblCliente" prependId="false">
<p:dataTable
id="tblCliente"
value="#{cadClienteMB.listar()}" var="p"
emptyMessage="Nenhum registro encontrado..."
widgetVar="cadClienteTable"
paginator="true" rows="5" rowsPerPageTemplate="5,10,15">
<f:facet name="header">
<p:outputPanel>
<div style="text-align: left; float: left">
<h:outputText value="Localizar:" />
<p:inputText id="globalFilter" onkeyup="cadClienteTable.filter()" style="width:150px" />
</div>
<div style="text-align: right; float: right">
<p:commandButton value="Novo"
oncomplete="dialogCliente.show()"
update=":frmClienteModal:infosCliente, :frmMsgErro:pnlMsgErros">
<f:setPropertyActionListener target="#{cadClienteMB.addNewReg}" value="true" />
<f:setPropertyActionListener target="#{cadClienteMB.cadCliente}" value="#{null}" />
</p:commandButton>
</div>
</p:outputPanel>
</f:facet>
<p:column headerText="Código" style="text-align: center; width: 30px"
filterBy="#{p.codCliente}" filterStyle="display: none">
<h:outputLabel value="#{p.codCliente}" />
</p:column>
<p:column headerText="Nome" style="text-align: left"
filterBy="#{p.nmCliente}" filterStyle="display: none">
<h:outputLabel value="#{p.nmCliente}" />
</p:column>
<p:column headerText="Cidade" style="text-align: left"
filterBy="#{p.nmCidade }" filterStyle="display: none">
<h:outputLabel value="#{p.nmCidade}" />
</p:column>
<p:column headerText="Alterar" style="text-align: left; width: 1px">
<p:commandButton value="Alterar"
oncomplete="dialogCliente.show()"
update="@all, :frmClienteModal:infosCliente, :frmMsgErro:pnlMsgErros">
<f:setPropertyActionListener target="#{cadClienteMB.addNewReg}" value="false" />
<f:setPropertyActionListener target="#{cadClienteMB.cadCliente}" value="#{p}" />
</p:commandButton>
</p:column>
<p:column headerText="Excluir" style="text-align: left; width: 1px">
<p:commandButton value="Excluir"
onclick="confirmation.show()"
update=":frmRemoveCliente:confirme, :frmMsgErro:pnlMsgErros">
<f:setPropertyActionListener target="#{cadClienteMB.addNewReg}" value="false" />
<f:setPropertyActionListener target="#{cadClienteMB.cadCliente}" value="#{p}" />
</p:commandButton>
</p:column>
<f:facet name="footer">
<div style="text-align: right">
<h:outputLabel value="Quantidade: " />
<h:outputText value="#{cadClienteMB.totalCliente()}"/>
</div>
</f:facet>
</p:dataTable>
</h:form>
<p:dialog id="dialog" header="Cliente" widgetVar="dialogCliente"
onHide="jQuery('#cmdBtnCancel').click();"
appendToBody="true" resizable="false"
modal="true" showEffect="fade" width="500">
<h:form id="frmClienteModal" prependId="false">
<h:panelGrid id="infosCliente" columns="3" style="margin-bottom:10px">
<h:outputLabel for="codCli" value="Código:" />
<p:inputText id="codCli" value="#{cadClienteMB.cadCliente.codCliente}" disabled="true"/>
<p:message for="codCli" display="text"/>
<h:outputLabel for="nmCli" value="Nome:" />
<p:inputText id="nmCli" value="#{cadClienteMB.cadCliente.nmCliente}"
required="true" requiredMessage="Valor inválido">
<f:validateRequired />
</p:inputText>
<p:message for="nmCli" display="text" />
<h:outputLabel for="nmEnd" value="Endereço:" />
<p:inputText id="nmEnd" value="#{cadClienteMB.cadCliente.nmEndereco}" />
<p:message for="nmEnd" display="text"/>
<h:outputLabel for="nmBai" value="Bairro:" />
<p:inputText id="nmBai" value="#{cadClienteMB.cadCliente.nmBairro}" />
<p:message for="nmBai" display="text"/>
<h:outputLabel for="nmCid" value="Cidade:" />
<p:inputText id="nmCid" value="#{cadClienteMB.cadCliente.nmCidade}"/>
<p:message for="nmCid" display="text"/>
<h:outputLabel for="nmUF" value="Estado:" />
<p:selectOneMenu id="nmUF" value="#{cadClienteMB.cadCliente.nmUF}">
<f:selectItem itemLabel="Acre" itemValue="AC"/>
<f:selectItem itemLabel="Alagoas" itemValue="AL"/>
<f:selectItem itemLabel="Amapá" itemValue="AP"/>
<f:selectItem itemLabel="Amazonas" itemValue="AM"/>
<f:selectItem itemLabel="Bahia" itemValue="BA"/>
<f:selectItem itemLabel="Ceará" itemValue="CE"/>
<f:selectItem itemLabel="Distrito Federal" itemValue="DF"/>
<f:selectItem itemLabel="Espírito Santo" itemValue="ES"/>
<f:selectItem itemLabel="Goiás" itemValue="GO"/>
<f:selectItem itemLabel="Maranhão" itemValue="MA"/>
<f:selectItem itemLabel="Mato Grosso" itemValue="MT"/>
<f:selectItem itemLabel="Mato Grosso do Sul" itemValue="MS"/>
<f:selectItem itemLabel="Minas Gerais" itemValue="MG"/>
<f:selectItem itemLabel="Pará" itemValue="PA"/>
<f:selectItem itemLabel="Paraíba" itemValue="PB"/>
<f:selectItem itemLabel="Paraná" itemValue="PR"/>
<f:selectItem itemLabel="Pernambuco" itemValue="PE"/>
<f:selectItem itemLabel="Piauí" itemValue="PI"/>
<f:selectItem itemLabel="Rio de Janeiro" itemValue="RJ"/>
<f:selectItem itemLabel="Rio Grande do Norte" itemValue="RN"/>
<f:selectItem itemLabel="Rio Grande do Sul" itemValue="RS"/>
<f:selectItem itemLabel="Rondônia" itemValue="RO"/>
<f:selectItem itemLabel="Rorâima" itemValue="RR"/>
<f:selectItem itemLabel="Santa Catarina" itemValue="SC"/>
<f:selectItem itemLabel="São Paulo" itemValue="SP"/>
<f:selectItem itemLabel="Sergipe" itemValue="SE"/>
<f:selectItem itemLabel="Tocantins" itemValue="TO"/>
</p:selectOneMenu>
<p:message for="nmUF" display="text"/>
</h:panelGrid>
<p:separator />
<p:commandButton id="cmdBtnSalvar"
value="Salvar"
actionListener="#{cadClienteMB.salvar}"
update=":frmTblCliente:tblCliente, :frmMsgErro:pnlMsgErros, infosCliente"
oncomplete="handleRequest(xhr, status, args)" />
<script type="text/javascript">
function handleRequest(xhr, status, args)
{
if (!args.validationFailed)
{
dialogCliente.hide();
}/*
else
{
jQuery('#dialog').effect("shake", { times:3 }, 100);
}
*/
}
</script>
<p:commandButton id="cmdBtnCancel"
immediate="true"
oncomplete="dialogCliente.hide();"
update="infosCliente"
value="Cancelar"/>
</h:form>
</p:dialog>
<h:form id="frmRemoveCliente" prependId="false">
<p:confirmDialog id="confirmDialog" message="Confirma exclusão do cliente ?"
header="Confirme" severity="alert" widgetVar="confirmation" appendToBody="true" >
<p:commandButton id="confirme" value="Sim"
oncomplete="confirmation.hide()"
update=":frmTblCliente:tblCliente, :frmMsgErro:pnlMsgErros"
actionListener="#{cadClienteMB.remover}"/>
<p:commandButton id="decline" immediate="true" value="Não" onclick="confirmation.hide()" />
</p:confirmDialog>
</h:form>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mb;
import dao.CadClienteDAO;
import entidade.CadCliente;
import java.sql.SQLException;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIParameter;
import javax.faces.event.ActionEvent;
/**
*
* @author edson.domenech
*/
@ManagedBean
@SessionScoped
public class CadClienteMB {
private CadCliente cadCliente;
private CadClienteDAO cadClienteDAO;
private List<CadCliente> listCadCliente;
private boolean addNewReg;
private boolean showMsgErros;
public CadClienteMB() throws Exception
{
this.cadCliente = new CadCliente();
this.cadClienteDAO = new CadClienteDAO();
this.showMsgErros = false;
atualizaList();
}
public List<CadCliente> listar() throws SQLException
{
return listCadCliente;
}
public int totalCliente() throws SQLException
{
return listCadCliente.size();
}
private void atualizaList() throws SQLException, Exception
{
listCadCliente = this.cadClienteDAO.listar();
}
public void salvar(ActionEvent Evento) throws SQLException, Exception
{
try
{
this.showMsgErros = false;
if (addNewReg)
{
this.cadCliente.setCodCliente(this.cadClienteDAO.proxCodCliente());
if (!this.cadClienteDAO.inserir(this.cadCliente))
{
this.showMsgErros = true;
}
}
else
{
if (!this.cadClienteDAO.alterar(this.cadCliente))
{
this.showMsgErros = true;
}
}
}
finally
{
atualizaList();
}
}
public void remover(ActionEvent Evento) throws SQLException, Exception
{
try
{
this.showMsgErros = false;
if (!this.cadClienteDAO.remover(this.cadCliente))
{
this.showMsgErros = true;
}
}
finally
{
atualizaList();
}
}
public CadCliente getCadCliente()
{
return cadCliente;
}
public void setCadCliente(CadCliente cadCliente)
{
if (cadCliente == null)
{
this.cadCliente = new CadCliente();
this.cadCliente.setNmUF("SC");
}
else
{
this.cadCliente = cadCliente;
}
}
public boolean isShowMsgErros()
{
return showMsgErros;
}
public void setShowMsgErros(boolean showMsgErros)
{
this.showMsgErros = showMsgErros;
}
public boolean isAddNewReg()
{
return addNewReg;
}
public void setAddNewReg(boolean addNewReg)
{
this.addNewReg = addNewReg;
}
}
Poderiam me da uma luz ?