Doubt on popular combobox giving setAttribute Java Web - Servlet, jsp

Asked

Viewed 62 times

1

Why are not populating the two combobox? It seems that when I leave two setAttribute, it considers only one...

inserir a descrição da imagem aqui

This is the combobox of the filled groups... Java class code in the Command package:

package command;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.AvaliacaoSemanal;
import model.Entrega;
import model.GrupoDeAlunos;
import model.Turma;
import model.Usuario;
import service.AvaliacaoSemanalService;
import service.EntregaServ;
import service.GrupoAlunosServ;
import service.TurmaService;
import service.UsuarioService;

public class PreencheComboGrupo implements Command {

    @Override
    public void executar(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        //EntregaServ ent = new EntregaServ();
        //Entrega entrega = new Entrega();
        GrupoAlunosServ GrupoAlunosServ = new GrupoAlunosServ();
        GrupoDeAlunos gps = new GrupoDeAlunos();
        RequestDispatcher view = null;
        HttpSession session = request.getSession();
        int usuarioid = (int) request.getSession().getAttribute("usuarioid");

        int fkusuario = 0;

        String id = request.getParameter("grupoid");
        //String ide = request.getParameter("entregaId");
        int grupoid = 0;
    //  int entregaid = 0;
        try {
            grupoid = Integer.parseInt(id);
        } catch (NumberFormatException e) {

        }
    //  try {
    //      entregaid = Integer.parseInt(ide);
    //  } catch (NumberFormatException e) {

    //  }
    //  entrega.setIdEntrega(entregaid);
        gps.setId(grupoid);
        try {
            fkusuario = usuarioid;
        } catch (NumberFormatException e) {
        }

        List<GrupoDeAlunos> listo = null;
        //List<Entrega> liste = null;

        //liste = ent.consultaTodasEntregas();
        listo = GrupoAlunosServ.filtraGrupos(fkusuario);
        view = request.getRequestDispatcher("AvaliarGrupo.jsp");
        request.getSession().setAttribute("listo", listo);
        //request.getSession().setAttribute("liste", liste);

        view.forward(request, response);



    }

}

You see, I’ve commented on the parts of the code that populate the delivery combobox... NOW, if I remove the comments I would expect you to populate the two combobox in JSP, but this is what happens:

inserir a descrição da imagem aqui

package command;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.AvaliacaoSemanal;
import model.Entrega;
import model.GrupoDeAlunos;
import model.Turma;
import model.Usuario;
import service.AvaliacaoSemanalService;
import service.EntregaServ;
import service.GrupoAlunosServ;
import service.TurmaService;
import service.UsuarioService;

public class PreencheComboGrupo implements Command {

    @Override
    public void executar(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        EntregaServ ent = new EntregaServ();
        Entrega entrega = new Entrega();
        GrupoAlunosServ GrupoAlunosServ = new GrupoAlunosServ();
        GrupoDeAlunos gps = new GrupoDeAlunos();
        RequestDispatcher view = null;
        HttpSession session = request.getSession();
        int usuarioid = (int) request.getSession().getAttribute("usuarioid");

        int fkusuario = 0;

        String id = request.getParameter("grupoid");
        String ide = request.getParameter("entregaId");
        int grupoid = 0;
        int entregaid = 0;
        try {
            grupoid = Integer.parseInt(id);
        } catch (NumberFormatException e) {

        }
        try {
            entregaid = Integer.parseInt(ide);
        } catch (NumberFormatException e) {

        }
        entrega.setIdEntrega(entregaid);
        gps.setId(grupoid);
        try {
            fkusuario = usuarioid;
        } catch (NumberFormatException e) {
        }

        List<GrupoDeAlunos> listo = null;
        List<Entrega> liste = null;

        liste = ent.consultaTodasEntregas();
        listo = GrupoAlunosServ.filtraGrupos(fkusuario);
        view = request.getRequestDispatcher("AvaliarGrupo.jsp");
        request.getSession().setAttribute("listo", listo);
        request.getSession().setAttribute("liste", liste);

        view.forward(request, response);

    }

}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.