I have a method in controller
that has the function to make a query in my database and after returning only one field of this search, however I am taking nullpointer
in the first for
that I am using. I would like help in that.
The constants are these:
private List<String> listaNomeProjeto;
private List<String> listaNomePerfil;
private List<String> listaNomeJornada;
@RequestMapping(value = REDIRECT_PAGE_CADASTRO, method = RequestMethod.GET)
public ModelAndView viewCadastro(Model model) {
List<Projeto> listaCompletaProjeto = projetoService.findAll();
for (Projeto listaProjetos : listaCompletaProjeto) {
listaNomeProjeto.add(listaProjetos.getProjeto());
}
List<Perfil> listaCompletaPerfil = perfilService.findAll();
for (Perfil listaPerfis : listaCompletaPerfil) {
listaNomePerfil.add(listaPerfis.getPerfil().toString());
}
List<Jornada> listaCompletaJornada = jornadaService.findAll();
for (Jornada listaJornadas : listaCompletaJornada) {
listaNomeJornada.add(listaJornadas.getDsJornada().toString());
}
usuarioBean = new UsuarioBean(listaNomeProjeto, listaNomePerfil, listaNomeJornada);
model.addAttribute("usuarioBean", usuarioBean);
return new ModelAndView(REQUEST_MAPPING_PAGE_CADASTRO);
}
Thank you in advance!