Bom galera, já vários tópicos e discussões sobre o meu problema, mas nenhum não conseguiu resolver o meu problema, que é o seguinte, em um cadastro simples de Pessoa, no meu arquivo xhtml não aparece as tags do primefaces, segue o código das classes:
PessoaModel
[code]package model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;
import org.hibernate.validator.Length;
import org.springframework.format.annotation.DateTimeFormat;
@Entity
@Table(name=“pessoa”)
public class Pessoa {
@Id
@SequenceGenerator(name = "sequence_pessoa", sequenceName = "sequence_pessoa", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence_pessoa")
private Long id;
@Length(max=60)
private String nome;
@Length(max=100)
private String email;
@Length(max=14)
private String cpf_cnpj;
@Length(max=10)
private String senha;
@Temporal(value=TemporalType.DATE)
@DateTimeFormat(pattern="dd/MM/yyyy")
private Date dt_nascimento;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCpf_cnpj() {
return cpf_cnpj;
}
public void setCpf_cnpj(String cpf_cnpj) {
this.cpf_cnpj = cpf_cnpj;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public Date getDt_nascimento() {
return dt_nascimento;
}
public void setDt_nascimento(Date dt_nascimento) {
this.dt_nascimento = dt_nascimento;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((cpf_cnpj == null) ? 0 : cpf_cnpj.hashCode());
result = prime * result
+ ((dt_nascimento == null) ? 0 : dt_nascimento.hashCode());
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((nome == null) ? 0 : nome.hashCode());
result = prime * result + ((senha == null) ? 0 : senha.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Pessoa other = (Pessoa) obj;
if (cpf_cnpj == null) {
if (other.cpf_cnpj != null)
return false;
} else if (!cpf_cnpj.equals(other.cpf_cnpj))
return false;
if (dt_nascimento == null) {
if (other.dt_nascimento != null)
return false;
} else if (!dt_nascimento.equals(other.dt_nascimento))
return false;
if (email == null) {
if (other.email != null)
return false;
} else if (!email.equals(other.email))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (nome == null) {
if (other.nome != null)
return false;
} else if (!nome.equals(other.nome))
return false;
if (senha == null) {
if (other.senha != null)
return false;
} else if (!senha.equals(other.senha))
return false;
return true;
}
}[/code]
PessoaDao
[code]package dao;
import java.util.List;
import model.Pessoa;
import org.hibernate.Criteria;
import org.hibernate.Session;
import util.HibernateUtil;
public class PessoaDao {
private Session session;
public void inserir(Pessoa pessoa){
session = HibernateUtil.getSessionFactory().openSession();
try{
session.beginTransaction();
session.save(pessoa);
session.getTransaction().commit();
}finally{
session.close();
}
}
public void alterar(Pessoa pessoa){
session = HibernateUtil.getSessionFactory().openSession();
try{
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.saveOrUpdate(pessoa);
session.getTransaction().commit();
}finally{
session.close();
}
}
public void excluir(Pessoa pessoa){
session = HibernateUtil.getSessionFactory().openSession();
try{
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.delete(pessoa);
session.getTransaction().commit();
}finally{
session.close();
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public List listar(){
session = HibernateUtil.getSessionFactory().openSession();
try{
Criteria cri = session.createCriteria(Pessoa.class);
return cri.list();
}finally{
session.close();
}
}
}[/code]
PessoaBean
[code]package bean;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import model.Pessoa;
import dao.PessoaDao;
@ManagedBean(name=“pessoaBean”)
@ViewScoped
public class PessoaBean {
Pessoa pessoa = new Pessoa();
@SuppressWarnings("rawtypes")
List pessoas = new ArrayList();
//construtor
public PessoaBean(){
pessoas = new PessoaDao().listar();
pessoa = new Pessoa();
}
public void cadastrar(ActionEvent actionEvent){
new PessoaDao().inserir(pessoa);
pessoas = new PessoaDao().listar();
pessoa = new Pessoa();
}
public void alterar(ActionEvent actionEvent){
new PessoaDao().alterar(pessoa);
pessoas = new PessoaDao().listar();
pessoa = new Pessoa();
}
public void excluir(ActionEvent actionEvent){
new PessoaDao().excluir(pessoa);
pessoas = new PessoaDao().listar();
pessoa = new Pessoa();
}
//getters and setters
public Pessoa getPessoa() {
return pessoa;
}
public void setPessoa(Pessoa pessoa) {
this.pessoa = pessoa;
}
public List getPessoas() {
return pessoas;
}
public void setPessoas(List pessoas) {
this.pessoas = pessoas;
}
}
[/code]
pessoa.xhtml
[code]
<h:body>
<div align="center">
<h:form id="formPrincipal">
<p:dataTable var="lista" value="#{pessoaBean.pessoas}"
id="tabelaPessoas" style="width:70%">
<f:facet name="header">Lista de Pessoas</f:facet>
<p:column headerText="Nome">
<h:outputText value="#{lista.nome}" />
</p:column>
<p:column headerText="Data Nascimento">
<h:outputText value="#{lista.dt_nascimento}" />
</p:column>
<p:column headerText="Email">
<h:outputText value="#{lista.email}" />
</p:column>
<p:column headerText="CPF/CNPJ">
<h:outputText value="#{lista.cpf_cnpj}" />
</p:column>
<p:column headerText="Ações">
<p:commandLink title="Alterar" update=":formAlterar:Alterar"
oncomplete="dialogAlterar.show()" immediate="true">
<p:graphicImage value="./imagens/edit_icon.png" />
<f:setPropertyActionListener target="#{pessoaBean.pessoa}"
value="#{lista}" />
</p:commandLink>
<p:commandLink title="Excluir" update=":formExcluir:Excluir"
oncomplete="confirmation.show()" immediate="true">
<p:graphicImage value="./imagens/del_icon.png" />
<f:setPropertyActionListener target="#{pessoaBean.pessoa}"
value="#{lista}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:commandButton value="Cadastrar" id="cadastrar"
oncomplete="dialogCadastrar.show()" />
</h:form>
</div>
<h:form id="formAlterar">
<p:dialog header="Alterar" widgetVar="dialogAlterar" modal="true"
id="Alterar">
<p:panelGrid id="panelAlterar" columns="2">
<h:outputText value="Nome:" />
<p:inputText value="#{pessoaBean.pessoa.nome}" />
<h:outputText value="Data Nascimento" />
<p:inputText value="#{pessoaBean.pessoa.dt_nascimento}" />
<h:outputText value="Email" />
<p:inputText value="#{pessoaBean.pessoa.email}" />
<h:outputText value="CPF/CNPJ" />
<p:inputText value="#{pessoaBean.pessoa.cpf_cnpj}" />
<h:outputText value="Senha" />
<p:inputText value="#{pessoaBean.pessoa.senha}" />
</p:panelGrid>
<p:commandButton value="Alterar"
actionListener="#{pessoaBean.alterar}"
update=":formPrincipal:tabelaPessoas"
oncomplete="dialogAlterar.hide()" />
</p:dialog>
</h:form>
<h:form id="formCadastrar">
<p:dialog header="Cadastrar" widgetVar="dialogCadastrar" modal="true">
<p:panelGrid id="panelCadastrar" columns="2">
<h:outputText value="Nome:" />
<p:inputText value="#{pessoaBean.pessoa.nome}" />
<h:outputText value="Data Nascimento" />
<p:inputText value="#{pessoaBean.pessoa.dt_nascimento}" />
<h:outputText value="Email" />
<p:inputText value="#{pessoaBean.pessoa.email}" />
<h:outputText value="CPF/CNPJ" />
<p:inputText value="#{pessoaBean.pessoa.cpf_cnpj}" />
<h:outputText value="Senha" />
<p:inputText value="#{pessoaBean.pessoa.senha}" />
</p:panelGrid>
<p:commandButton value="Cadastrar"
actionListener="#{pessoaBean.cadastrar}"
update=":formPrincipal:tabelaPessoas"
oncomplete="dialogCadastrar.hide()" />
</p:dialog>
</h:form>
<h:form id="formExcluir">
<p:confirmDialog id="Excluir"
message="Você gostaria de Excluir #{pessoaBean.pessoa.nome}?"
header="Excluir" severity="alert" widgetVar="confirmation">
<p:commandButton id="confirm" value="Sim"
oncomplete="confirmation.hide()"
actionListener="#{pessoaBean.excluir}"
update=":formPrincipal:tabelaPessoas" />
<p:commandButton id="decline" value="Não"
onclick="confirmation.hide()" type="button" />
</p:confirmDialog>
</h:form>
</h:body>
[/code]web.xml
[code]<?xml version="1.0" encoding="UTF-8" ?>
Sistema de AutoPecas
SAP
javax.faces.PROJECT_STAGE
Production
javax.facelets.REFRESH_PERIOD
10
javax.faces.DEFAULT_SUFFIX
.xhtml
javax.faces.STATE_SAVING_METHOD
server
org.ajax4jsf.VIEW_HANDLERS
com.sun.facelets.FaceletViewHandler
com.sun.faces.validateXml
true
com.sun.faces.verifyObjects
false
com.sun.faces.enableRestoreView11Compatibility
true
org.ajax4jsf.handleViewExpiredOnClient
true
javax.facelets.BUILD_BEFORE_RESTORE
true
hibernateLocation
/WEB-INF/classes/hibernate.properties
javax.faces.CONFIG_FILES
/WEB-INF/faces-config.xml
log4jConfigLocation
/WEB-INF/classes/log4j.properties
Resource Servlet
org.primefaces.resource.ResourceServlet
Resource Servlet
/primefaces_resource/
primefaces.skin
none
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/app/
30
app/index.xhtml
[/code]
Então, ele executa tudo certo, mas aparece apenas o título do meu pessoa.xhtml que é Lista de Pessoas.
Alguém pode me ajudar? Vou ficar no aguardo. Abraços!