Olha como o meu está. Estou com dois problemas para terminar esta tela. Estou fazendo como você, todas as operações faço na mesma tela.
Meu primeiro problema é, como tenho um campo obrigatório (required=“true”) não consigo editar. Ele sempre pede “rg obrigatório”.
<h:outputText value="RG:"/>
<h:inputText id="rg" value="#{PessoaView.pes.rg}" required="#{PessoaView.reqValid}" requiredMessage="RG é obrigatório!">
<rich:ajaxValidator event="onblur"/>
</h:inputText>
<rich:message for="rg"/>
Aqui está meu link editar. Que no caso carregaria o formulário com os registros do banco de dados. Mas como o rg é obrigatório não deixa de jeito nenhum. Quando coloco immediate = “true” no link só carrega o id.
<a4j:commandLink reRender="painelCadastro,grid" action="#{PessoaView.testaBotao}">
<h:graphicImage styleClass="link" url="imagens/rtg_rate.gif" title="Alterar"/>
<f:setPropertyActionListener value="#{item}" target="#{PessoaView.pes}"/>
</a4j:commandLink>
E o segundo problema é quanto as mensagem quando executo os métodos. Como que faz pra quando um método é executado aparecer uma mensagem da situação dele. Se deu certo ou não.
Abaixo está todo meu código.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@taglib uri="http://richfaces.org/rich" prefix="rich" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pessoa</title>
<style type="text/css">
.linha_a{
background-color: #C6E2FF;
text-align: center;
padding: 8px;
font-family: Arial;
font-size: 12px;
}
.linha_b{
background-color: white;
text-align: center;
padding: 8px;
font-family: Arial;
font-size: 12px;
}
.tabela{
margin-left: auto;
margin-right: auto;
width: 600px;
}
.cabecalho{
text-align: center;
color: black;
background: white;
font-family: Arial;
font-size: 12px;
padding:5px;
}
.cabecalhoCad{
PADDING-RIGHT: 3px;
PADDING-LEFT: 3px;
background-color: #31659C;
font-size: 11px;
COLOR: #ffffff;
font-weight: bol
}
.linhasCad{
background-color: white;
font-family: Arial;
font-size: 12px;
}
.tabelaCad{
width: 600px;
margin-left: auto;
margin-right: auto;
}
.botao{
background-color: #104E8B;
color: white;
border-color: black;
}
.tabelaBot{
margin-left: auto;
margin-right: auto;
}
.link{
border: none;
}
.field {
PADDING-RIGHT: 3px;
PADDING-LEFT: 3px;
PADDING-BOTTOM: 2px;
PADDING-TOP: 2px }
.label {
PADDING-RIGHT: 3px;
PADDING-LEFT: 3px;
PADDING-BOTTOM: 2px;
PADDING-TOP: 2px;
background-color: #f6f6f6;
text-align:right }
</style>
</head>
<body>
<f:view>
<rich:tabPanel switchType="client" id="abasCadastro">
<rich:tab label="Home">
novo
</rich:tab>
<rich:tab label="Pessoa" id="Pessoa">
<h:form id="cadastro">
<h:panelGrid columnClasses="label, field" id="painelCadastro" styleClass="tabelaCad" headerClass="cabecalhoCad" border="0" columns="3">
<f:facet name="header">
<h:outputText value="Pessoa"/>
</f:facet>
<h:outputText value="Identificador:"/>
<h:inputText id="identificador" value="#{PessoaView.pes.identificador}" disabled="true"/>
<h:message for="identificador"/>
<h:outputText value="RG:"/>
<h:inputText id="rg" value="#{PessoaView.pes.rg}" required="#{PessoaView.reqValid}" requiredMessage="RG é obrigatório!">
<rich:ajaxValidator event="onblur"/>
</h:inputText>
<rich:message for="rg"/>
<h:outputText value="Município:"/>
<h:inputText id="municipio" value="#{PessoaView.pes.municipio}"/>
<h:message for="municipio"/>
<h:outputText value="Órgão Expeditor:"/>
<h:inputText id="rgorgaoexp" value="#{PessoaView.pes.rgorgaoexp}"/>
<h:message for="rgorgaoexp"/>
<h:outputText value="Data Emissão RG:"/>
<rich:calendar id="rgemissao" value="#{PessoaView.pes.rgemissao}" datePattern="yyyy-MM-dd" converter="converteAnoMySQL"/>
<h:message for="rgemissao"/>
<h:outputText value="CPF:"/>
<h:inputText id="cpf" value="#{PessoaView.pes.cpf}"/>
<h:message for="cpf"/>
<h:outputText value="Sexo:"/>
<h:inputText maxlength="1" id="sexo" value="#{PessoaView.pes.sexo}"/>
<h:message for="sexo"/>
<h:outputText value="Título Eleitoral:"/>
<h:inputText id="titeleitoral" value="#{PessoaView.pes.titeleitoral}"/>
<h:message for="titeleitoral"/>
<h:outputText value="Email:"/>
<h:inputText id="email" value="#{PessoaView.pes.email}"/>
<h:message for="email"/>
<h:outputText value="Endereço:"/>
<h:inputText id="endereco" value="#{PessoaView.pes.endereco}"/>
<h:message for="endereco"/>
<h:outputText value="#{PessoaView.reqValid}"/>
</h:panelGrid>
<br />
<h:panelGrid columns="5" styleClass="tabelaBot" id="grid">
<a4j:commandButton value="Cadastrar" status="sts" id="botCadastrar" rendered="#{PessoaView.botCad}" styleClass="botao" reRender="painel" action="#{PessoaView.create}"/>
<a4j:commandButton value="Alterar" id="botAlterar" rendered="#{PessoaView.botAlt}" styleClass="botao" reRender="painel" action="#{PessoaView.update}"/>
<a4j:commandButton status="sts" value="Listar" immediate="true" reRender="painel" styleClass="botao" action="#{PessoaView.mudaListar}" />
<a4j:commandButton value="Limpar" styleClass="botao" reRender="painelCadastro, grid" action="#{PessoaView.limpa}"/>
</h:panelGrid>
<br />
<rich:messages />
<a4j:region id="regiaoAJAX">
<a4j:status id="sts">
<f:facet name="start">
<h:graphicImage value="/imagens/AJAX_03.gif" />
</f:facet>
</a4j:status>
</a4j:region>
<br />
<rich:panel id="painel" style="border:none;">
<rich:dataTable id="listaCliente" rows="5" rowClasses="linha_a, linha_b" styleClass="tabela" headerClass="cabecalho" value="#{PessoaView.allPessoas}" var="item"
rendered="#{PessoaView.listar}" cellpadding="2" cellspacing="0">
<f:facet name="header">
<h:outputText value="Pessoas Cadastradas"/>
</f:facet>
<rich:column>
<f:facet name="header">
<h:outputText value="RG"/>
</f:facet>
<h:outputText value="#{item.rg}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Municipio"/>
</f:facet>
<h:outputText value="#{item.municipio}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="CPF"/>
</f:facet>
<h:outputText value="#{item.cpf}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Sexo"/>
</f:facet>
<h:outputText value="#{item.sexo}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="E-Mail"/>
</f:facet>
<h:outputText value="#{item.email}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Operação"/>
</f:facet>
<a4j:commandLink reRender="painelCadastro,grid" action="#{PessoaView.testaBotao}">
<h:graphicImage styleClass="link" url="imagens/rtg_rate.gif" title="Alterar"/>
<f:setPropertyActionListener value="#{item}" target="#{PessoaView.pes}"/>
</a4j:commandLink>
<a4j:commandLink immediate="true" reRender="painel" action="#{PessoaView.delete}">
<h:graphicImage styleClass="link" url="imagens/bRmv.gif" title="Apagar"/>
<f:setPropertyActionListener value="#{item.identificador}" target="#{PessoaView.identificador}"/>
</a4j:commandLink>
</rich:column>
<f:facet name="footer">
<rich:datascroller id="paginacao" for="listaCliente" rendered="#{PessoaView.listar}"/>
</f:facet>
</rich:dataTable>
</rich:panel>
</h:form>
</rich:tab>
</rich:tabPanel>
</f:view>
</body>
</html>
Desde já agradeço a atenção.
Abraço