Boa noite a todos;
Alguém poderia me ajudar, e me dizer o que posso estar fazendo errado, eu preciso listar três campos na minha dataTable, mas, sem sucesso.
Olhem o código!
[code]<%@taglib prefix=“h” uri=“http://java.sun.com/jsf/html” %>
<%@taglib prefix=“f” uri=“http://java.sun.com/jsf/core” %>
<%@ taglib prefix=“rich” uri=“http://richfaces.ajax4jsf.org/rich”%>
<%@page contentType=“text/html” pageEncoding=“UTF-8”%>
<f:view>
Exemplo de DataTable
Montando um DataTable de CADASTROS
<h:form id="dataTable">
<center><rich:dataTable value="#{ClienteDao.todosClientes}" var="clientes" rows="10" id="table"></center>
<f:facet name="header">
<h:outputText id="listaClientes" value="TODOS OS CLIENTES CADASTRADOS"/>
</f:facet>
<rich:column>
<f:facet name="header">
<h:outputText id="NomeID"/>
</f:facet>
<h:outputText id="nome" value="#{clientes.nome}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText id="EmailID"/>
</f:facet>
<h:outputText id="email" value="#{clientes.email}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText id="CpfID"/>
</f:facet>
<h:outputText id="cpf" value="#{clientes.cpf}"/>
</rich:column>
<h:commandButton id="botao" value="pesquisar" action="#{cliente.pesquisarTodos}"/>
</rich:dataTable>
</h:form>
</body>
</html>
</f:view>[/code]
E na minha classe Bean tenho:
public class ClienteBean
{
private String nome;
private String cpf;
private String email;
public ClienteBean() {}
public ClienteBean(String nome, String email, String cpf)
{
this.nome = nome;
this.email = email;
this.cpf = cpf;
}
// Metodos getters e setters;
public void pesquisarTodos() throws SQLException
{
ClienteDao dao = new ClienteDao();
dao.carregarDados(this);
List<ClienteBean> todosClientes = dao.carregarDados(this);
}
E também tenho minha classe DAO;
public List<ClienteBean> carregarDados(ClienteBean cliente) throws SQLException
{
String sql = "SELECT NOME, EMAIL, CPF FROM tb_cliente";
List <ClienteBean>todosClientes = new ArrayList<ClienteBean>();
stmt = conexao.prepareStatement(sql);
rs = stmt.executeQuery();
while(rs.next())
{
cliente.setNome(rs.getString("NOME"));
cliente.setEmail(rs.getString("EMAIL"));
cliente.setCpf(rs.getString("CPF"));
todosClientes.add(cliente);
}
rs.close();
stmt.close();
return todosClientes;
Se alguém conseguir me ajudar eu agradeço muito
obrigado!