Pessoal ao acionar meu comandlink o JSF reporta o seguinte erro
javax.el.PropertyNotFoundException: /cadastroCliente.xhtml @81,23 value="#{mbCliente.cliente.nome}": Target Unreachable, 'cliente' returned null
Ja, fucei tudo e não achei uma solução , gostaria da ajuda de você
MEU XHTML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Cadastro de Clientes</title>
</h:head>
<h:body>
<h:form id="frmCliente">
<p:messages/>
<p:dataTable widgetVar="dtClientes"
var="cliente"
value="#{mbCliente.clientes}"
paginator="true"
rows="10"
selection="#{mbCliente.cliente}"
selectionMode="single"
onRowSelectUpdate="display"
onRowSelectComplete="dlgCliente.show()"
style="width:70%">
<p:column sortBy="#{cliente.id}"
filterBy="#{cliente.id}"
style="width:20%">
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
</p:column>
<p:column sortBy="#{cliente.nome}"
filterBy="#{cliente.nome}">
<f:facet name="header">
<h:outputText value="Nome" />
</f:facet>
</p:column>
<p:column sortBy="#{cliente.cnpj}"
filterBy="#{cliente.cnpj}">
<f:facet name="header">
<h:outputText value="Cnpj" />
</f:facet>
</p:column>
</p:dataTable>
<p:panel style="width:69.2%">
<h:commandLink title="Novo" // AO CLICAR REPORTA O ERRO JA TROQUEI DE JSF (h:commandLink ) para Prime(p:commandLink ) mais nada
oncomplete="dlgCliente.show();">
<h:graphicImage url="/imagens/novo.jpg"
style="border:0"/>
</h:commandLink>
<p:commandLink title="Apagar"
action="#{mbCliente.apagar}"
style="margin-left:20px"
update="dtClientes">
<h:graphicImage url="/imagens/apagar.jpg"
style="border:0"/>
</p:commandLink>
<p:commandLink title="Voltar"
action="#{mbCliente.voltar}"
ajax="false"
style="margin-left:20px">
<h:graphicImage url="/imagens/voltar.jpg"
style="border:0"/>
</p:commandLink>
</p:panel>
<p:dialog id="dlgCliente"
widgetVar="dlgCliente"
header="Cliente"
showEffect="bounce"
width="500">
<p:messages/>
<h:panelGrid columns="2">
<h:outputLabel value="Id"
for="itxId" />
<h:inputText id="itxId"
value="#{mbCliente.cliente.id}"
disabled="true"/>
<h:outputLabel value="Nome"
for="itxNome" />
<h:inputText id="itxNome"
value="#{mbCliente.cliente.nome}"
size="35"/>
<h:outputLabel value="CNPJ"
for="itxCnpj" />
<h:inputText id="itxCnpj"
value="#{mbCliente.cliente.cnpj}"/>
</h:panelGrid>
<h:panelGrid columns="3">
<p:commandLink title="Gravar"
action="#{mbCliente.gravar}"
rendered="#{empty mbCliente.cliente.id}"
update="dtClientes"
ajax="false">
<h:graphicImage url="/imagens/gravar.jpg"
style="border:0"/>
</p:commandLink>
<p:commandLink title="Alterar"
actionListener="#{mbCliente.alterar}"
rendered="#{!empty mbCliente.cliente.id}"
update="dtClientes">
<h:graphicImage url="/imagens/alterar.jpg"
style="border:0"/>
</p:commandLink>
</h:panelGrid>
</p:dialog>
</h:form>
</h:body>
</html>
meu MBCliente
[code]
package controladores;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import negocios.ClienteBO;
import entidades.Cliente;
@ManagedBean(name=“mbCliente”)
@ViewScoped
public class MBCliente implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4718957167100835066L;
private ClienteBO clienteBO;
private Cliente cliente;
private List<Cliente> clientes;
public MBCliente(){
this.setClienteBO(new ClienteBO());
this.setCliente(new Cliente());
this.setClientes(new ArrayList<Cliente>());
}
public ClienteBO getClienteBO() {
return clienteBO;
}
public void setClienteBO(ClienteBO clienteBO) {
this.clienteBO = clienteBO;
}
public Cliente getCliente() {
return cliente;
}
public void setCliente(Cliente cliente) {
this.cliente = cliente;
}
public List<Cliente> getClientes() {
return clientes;
}
public void setClientes(List<Cliente> clientes) {
this.clientes = clientes;
}
public void gravar(){
try {
this.getClienteBO().gravar(this.getCliente());
this.getClientes().add(this.getCliente());
this.setCliente(new Cliente());
JSFUtil.enviarMenssagemSucesso("Cliente gravado com sucesso");
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao gravar"+" "+e.getMessage() );
}
}
public void alterar(ActionEvent evento) {
try {
this.getClienteBO().gravar(this.getCliente());
this.getClientes().remove(this.getCliente());
this.getClientes().add(this.getCliente());
JSFUtil.enviarMenssagemSucesso("Cliente alterado com sucesso");
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao alterar"+" "+e.getMessage() );
}
}
public void apagar() {
try {
this.getClienteBO().gravar(this.getCliente());
this.getClientes().remove(this.getCliente());
JSFUtil.enviarMenssagemSucesso("Cliente apagado com sucesso");
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao apagar"+" "+e.getMessage() );
}
}
public List<Cliente> listar(){
List<Cliente> clientes = new ArrayList<Cliente>();
try {
clientes = this.getClienteBO().listar();
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao Listar"+" "+e.getMessage() );
}
return clientes;
}
public String voltar(){
return "index";
}
}[/code]
minha Classe Cliente
package entidades;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name="Cliente")
@Entity
public class Cliente implements Serializable{
private static final long serialVersionUID = -3385161602869622711L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id", nullable=false)
private Integer id;
@Column(name="nome", nullable=false)
private String nome;
@Column(name="cnpj", nullable=false)
private String cnpj;
public Cliente(){
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getCnpj() {
return cnpj;
}
public void setCnpj(String cnpj) {
this.cnpj = cnpj;
}
}
Não indendo este erro…
Deste ja agradeço