PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum Erro projeto simples de cadastro de cliente. #575026

16/02/2017

0

Erro no meu projeto simples de cadastro de cliente. Quando clico no botão cadastrar ocorre este erro:

HTTP Status 500 - /novo.xhtml @16,94 value="#{clienteBean.clienteVO.nome}": Target Unreachable, identifier 'clienteBean' resolved to null

type Exception report

message /novo.xhtml @16,94 value="#{clienteBean.clienteVO.nome}": Target Unreachable, identifier 'clienteBean' resolved to null

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: /novo.xhtml @16,94 value="#{clienteBean.clienteVO.nome}": Target Unreachable, identifier 'clienteBean' resolved to null
javax.faces.webapp.FacesServlet.service(FacesServlet.java:422)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


root cause


O Codigo da classe Bean:


package br.com.russosystem.Bean;


import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

import br.com.russosystem.DAO.ClienteDAO;
import br.com.russosystem.VO.ClienteVO;


@ManagedBean(name = "clienteBean")
public class ClienteBean{

	private ClienteVO clienteVO = new ClienteVO(); 
	private DataModel<ClienteVO> clientes;
	
	public DataModel<ClienteVO> getClientes() {
		ClienteDAO dao = new ClienteDAO();
		
		try {
			List<ClienteVO> lista = dao.getALL();
			clientes = new ListDataModel<ClienteVO>(lista);			
	  } catch (Exception e) {
	         }
		
		return clientes;
	}

	public void setClientes(DataModel<ClienteVO> clientes) {
		this.clientes = clientes;
	}

	public ClienteVO getClienteVO() {
		return clienteVO;
	}

	public void setClienteVO(ClienteVO clienteVO) {
		this.clienteVO = clienteVO;
	}

	public String addUser() {
		
		 String retorno = "erro";
		 
		try {
		    
			ClienteDAO dao = new ClienteDAO();
		    if (dao.insert(clienteVO)){
		    	retorno = "sucesso";
		    }
		 
		} catch (Exception ex){
			
      }
		return retorno;
	}
	
}



Código do Xml:


<!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:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
   <h:head>
    <link rel="stylesheet" type="text/css" href="site.css"/>   
   </h:head>
  <h:body>
	  <h:form>
	  <h:outputText value="Cadastro de Cliente" style="ont-size:20px;font-weight:bold"></h:outputText>
	    
</br>
	    <h:outputLabel value="Nome:"></h:outputLabel><br/>
	    <h:inputText id="nome" value="#{clienteBean.clienteVO.nome}" styleClass="estilo_campos"></h:inputText>	    	    
	    <br/><br/>
	    <h:outputLabel value="E-mail:"></h:outputLabel><br/>
	    <h:inputText id="email" value="#{clienteBean.clienteVO.email}" styleClass="estilo_campos"></h:inputText>
	    <br/><br/>
	    <h:outputLabel value="Idade:"></h:outputLabel><br/>
	    <h:inputText id="idade" value="#{clienteBean.clienteVO.idade}" styleClass="estilo_campos"></h:inputText>	
	    <br/><br/>
	    <h:commandButton action="#{clienteBean.addUser}" type="submit" value="Cadastrar" styleClass="button" ></h:commandButton>
	    <h:commandButton type="reset" value="Limpar" styleClass="button" ></h:commandButton>
	  </h:form>
   </h:body>	
</html>
Juliano Andrade

Juliano Andrade

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar