1

I've read a lot of similar topics on this subject, but not one of'em was able to sort this problem out. Can anyone help with the following situation?

I have a form using the foillowing SelectOneMenu

<h:outputText value="Gerente do Projeto: " />
            <p:selectOneMenu value="#{projetoBean.projeto.idGerente}"
            style="width:160px; font-size:110%;" 
            <f:selectItems value="#{projetoBean.gerentes}" />
            </p:selectOneMenu>

It is connected to this bean at the metthod bellow:

public void buscaGerentes(){
    List<SelectItem> gerentesAux = new ArrayList<SelectItem>();
    gerentesAux = recursoRN.listaGerentes();
    this.gerentes = gerentesAux;
}

Thos bean calls out to the follow BO:

public List<SelectItem> listaGerentes(){
    List<SelectItem> gerente = new ArrayList<SelectItem>();
    gerente = recursoDAO.listaGerentes();
    return gerente;

Finally this is the DAO that gets me my data to the selectonemenu:

public List<SelectItem> listaGerentes() {
    List<SelectItem> gerenteLista = new ArrayList<SelectItem>();
    Connection conexao = geraConexao();     
    Statement consulta = null;
    ResultSet resultado = null;
    Recurso recurso = null;
    String sql = "SELECT id_recurso, nome FROM rupecm.recurso WHERE id_perfil = 11 AND ativo = 1;";

    try {
        consulta = conexao.createStatement();
        resultado = consulta.executeQuery(sql);

        while (resultado.next()) {
            recurso = new Recurso();
            recurso.setIdRecurso(new Integer(resultado.getInt("id_recurso")));
            recurso.setNome(resultado.getString("nome"));               
            gerenteLista.add(new SelectItem(recurso.getIdRecurso(), recurso.getNome()));
            System.out.println("Recurso ID: "+recurso.getIdRecurso()+" | Nome: "+recurso.getNome());
        }

    } catch (SQLException e) {
        System.out.println("Erro ao buscar gerentes: " + e.getMessage());
        gerenteLista = null;
    } finally {
        try {
            consulta.close();
            resultado.close();
            conexao.close();
        } catch (Throwable e) {
            System.out.println("Erro ao fechar operação de consulta: "
                    + e.getMessage());
        }
    }
    return gerenteLista;
}

I keep getting the same error, wven though I have declared the equals and evething else. Can you tell me what I'm doing wrong?

Thank you so much for the help.

Best regards.

4

0 回答 0