Problemas com a referencia no managebean

Galera boa tarde, estou com problema no meu projeto mais exatamente na minha classe bean e xhtml… na hora de dar referencia as variaveis da minha classe Dao ou Dominio eu n consigo , segue abaixo minhas classes

package br.com.farmacia.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import br.com.farmacia.domain.Fornecedores;
import br.com.farmacia.factory.ConexaoFactory;

public class FornecedoresDAO {

public void salvar(Fornecedores f) throws SQLException {

	StringBuilder sql = new StringBuilder();

	sql.append("INSERT INTO fornecedores ");
	sql.append("(descricao)");
	sql.append("VALUES (?)");

	Connection conexao = ConexaoFactory.conectar();

	PreparedStatement comando = conexao.prepareStatement(sql.toString());

	comando.setString(1, f.getDescricao());
	comando.executeUpdate();

}

public void excluir(Fornecedores f) throws SQLException {

	StringBuilder sql = new StringBuilder();

	sql.append("DELETE FROM fornecedores ");
	sql.append("WHERE codigo = ? ");

	Connection conexao = ConexaoFactory.conectar();

	PreparedStatement comando = conexao.prepareStatement(sql.toString());

	comando.setLong(1, f.getCodigo());

	comando.executeUpdate();

}

public void editar(Fornecedores f) throws SQLException {

	StringBuilder sql = new StringBuilder();

	sql.append("UPDATE fornecedores ");
	sql.append("SET descricao = ? ");
	sql.append("WHERE codigo = ? ");

	Connection conexao = ConexaoFactory.conectar();

	PreparedStatement comando = conexao.prepareStatement(sql.toString());

	comando.setString(1, f.getDescricao());
	comando.setLong(2, f.getCodigo());

	comando.executeUpdate();

}

public Fornecedores buscaPorCodigo(Fornecedores f) throws SQLException {

	StringBuilder sql = new StringBuilder();

	sql.append("SELECT codigo, descricao ");
	sql.append("FROM fornecedores ");
	sql.append("WHERE codigo = ? ");

	Connection conexao = ConexaoFactory.conectar();

	PreparedStatement comando = conexao.prepareStatement(sql.toString());

	comando.setLong(1, f.getCodigo());

	ResultSet resultado = comando.executeQuery();

	Fornecedores retorno = null;

	if (resultado.next()) {

		retorno = new Fornecedores();

		retorno.setCodigo(resultado.getLong("codigo"));
		retorno.setDescricao(resultado.getString("descricao"));
	}

	return retorno;

}

public ArrayList<Fornecedores> listar() throws SQLException {

	StringBuilder sql = new StringBuilder();
	sql.append("SELECT codigo, descricao ");
	sql.append("FROM fornecedores ");
	sql.append("ORDER BY descricao ASC ");

	Connection conexao = ConexaoFactory.conectar();

	PreparedStatement comando = conexao.prepareStatement(sql.toString());

	ResultSet resultado = comando.executeQuery();

	ArrayList<Fornecedores> lista = new ArrayList<Fornecedores>();

	while (resultado.next()) {
		Fornecedores f = new Fornecedores();
		f.setCodigo(resultado.getLong("codigo"));
		f.setDescricao(resultado.getString("descricao"));

		lista.add(f);
	}
	return lista;
}

public ArrayList<Fornecedores> buscaPorNome(Fornecedores f) throws SQLException {

	StringBuilder sql = new StringBuilder();

	sql.append("SELECT codigo, descricao ");
	sql.append("FROM fornecedores ");
	sql.append("WHERE descricao LIKE ? ");
	sql.append("ORDER BY descricao ASC ");

	Connection conexao = ConexaoFactory.conectar();

	PreparedStatement comando = conexao.prepareStatement(sql.toString());

	comando.setString(1, "%" + f.getDescricao() + "%");

	ResultSet resultado = comando.executeQuery();

	ArrayList<Fornecedores> lista = new ArrayList<Fornecedores>();

	while (resultado.next()) {

		Fornecedores item = new Fornecedores();
		item.setCodigo(resultado.getLong("codigo"));
		item.setDescricao(resultado.getString("descricao"));

		lista.add(item);
	}
	return lista;
}

}
Na minha claase DAO todos metodos estao funcionando

package br.com.farmacia.bean;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.ListDataModel;

import br.com.farmacia.DAO.FornecedoresDAO;
import br.com.farmacia.domain.Fornecedores;

@ManagedBean(name = “MBFornecedores”)
@ViewScoped
public class FornecedoresBean {

private ListDataModel <Fornecedores> itens;
	
public ListDataModel<Fornecedores> getItens() {
		return itens;
}

public void setItens(ListDataModel<Fornecedores> itens) {
		this.itens = itens;
	}
	
	@PostConstruct
	public void prepararPesquisa() {
		
		try {
			FornecedoresDAO fdao = new FornecedoresDAO();
			ArrayList <Fornecedores> lista = fdao.listar();
			itens = new ListDataModel<Fornecedores> (lista);
			} 
		catch (SQLException e) {
			e.printStackTrace();
		}
	  }
	}

essa e minha classe bean aparentemente fiz as referencias certinhas

<?xml version="1.0" encoding="UTF-8" ?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h=“http://java.sun.com/jsf/html"
xmlns:f=“http://java.sun.com/jsf/core"
template=”/templates/modeloFarmacia.xhtml”>

<ui:define name="menu">
	<ui:include src="/includes/menu.xhtml">
	</ui:include>
</ui:define>

<ui:define name="conteudo">

	<p:dataTable emptyMessage="Nenhum registro encontrado"
		var="item" value="#{MBFornecedores.itens}" >
		
		<p:column headerText="codigo">
			<h:outputText value="#{item.codigo}" />
		</p:column>

		<p:column headerText="Descricao">
			<h:outputText value="#{item.descricao}" />
		</p:column>

	</p:dataTable>

</ui:define>

</ui:composition>

esse e o meu arquivo xhtml…quando eu inicio ele nao obtenho nenhuma resposta, me parece que nao estou referenciar as minhas variaveis codigo nem descricao

Colega,

Quando na sua view você for chamar seu managerBean lembre que tem que chamar com inicial minuscula, pois o JSF já instalaciou internamente.

Boa Andre, me desculpe a pergunta e pq estou aprendendo java agora , como seria a chamada, pq eu ja tentei aqui fazer o q vc fez e continua sem conseguir da referencia as variaveis

Tentar fazer essas modificações:

private List <Fornecedores> itens;

@PostConstruct
public void prepararPesquisa() {

	try {
		FornecedoresDAO fdao = new FornecedoresDAO();
		this.itens = fdao.listar();
		
		} 
	catch (SQLException e) {
		e.printStackTrace();
	}
  }

Eu suprimi o que não alterei, portanto, é pra manter todo o resto

Nao funcionou

:dizzy_face:

Exibe alguma mensagem de erro? Ou apenas não mostra os dados? No seu console ele mostra a consulta ao banco?

aqui sao as menssagens que aparecem no console com o meu codigo

out 31, 2017 10:24:47 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:Agenda’ did not find a matching property.
out 31, 2017 10:24:47 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:Farmacia’ did not find a matching property.
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version: Apache Tomcat/9.0.1
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built: Sep 27 2017 17:31:52 UTC
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number: 9.0.1.0
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name: Mac OS X
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version: 10.12.6
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture: x86_64
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version: 1.8.0_111-b14
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor: Oracle Corporation
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE: /Users/wep/Desktop/Sistema Farmacia/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME: /Users/wep/Desktop/Sistema Farmacia/SERVIDOR/apache-tomcat-9.0.1
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=/Users/wep/Desktop/Sistema Farmacia/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=/Users/wep/Desktop/Sistema Farmacia/SERVIDOR/apache-tomcat-9.0.1
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=/Users/wep/Desktop/Sistema Farmacia/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=/Users/wep/Desktop/Sistema Farmacia/SERVIDOR/apache-tomcat-9.0.1/endorsed
out 31, 2017 10:24:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=UTF-8
out 31, 2017 10:24:47 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/wep/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
out 31, 2017 10:24:47 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler [“http-nio-8080”]
out 31, 2017 10:24:47 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
out 31, 2017 10:24:47 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler [“ajp-nio-8009”]
out 31, 2017 10:24:47 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
out 31, 2017 10:24:47 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1340 ms
out 31, 2017 10:24:47 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service [Catalina]
out 31, 2017 10:24:47 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/9.0.1
out 31, 2017 10:24:52 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
out 31, 2017 10:24:56 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
out 31, 2017 10:24:57 PM com.sun.faces.config.ConfigureListener contextInitialized
INFORMAÇÕES: Inicializando Mojarra 2.2.9 (-SNAPSHOT 20141218-0939 https://svn.java.net/svn/mojarra~svn/tags/2.2.9@14083) para o contexto '/Agenda’
out 31, 2017 10:24:57 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes. Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.
out 31, 2017 10:24:59 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMAÇÕES: Running on PrimeFaces 4.0
out 31, 2017 10:25:02 PM org.apache.jasper.servlet.TldScanner scanJars
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
out 31, 2017 10:25:03 PM com.sun.faces.config.ConfigureListener contextInitialized
INFORMAÇÕES: Inicializando Mojarra 2.2.9 (-SNAPSHOT 20141218-0939 https://svn.java.net/svn/mojarra~svn/tags/2.2.9@14083) para o contexto '/Farmacia’
out 31, 2017 10:25:03 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes. Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.
out 31, 2017 10:25:04 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMAÇÕES: Running on PrimeFaces 4.0
out 31, 2017 10:25:04 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler [“http-nio-8080”]
out 31, 2017 10:25:04 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler [“ajp-nio-8009”]
out 31, 2017 10:25:04 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 16675 ms

Quando eu coloco seu codigo junto da erro na classe toda…

Não é pra você apenas colar meu codigo na pagina, é pra mudar o que eu alterei e manter o resto