-1
I have a Controller that the first thing he does is bring a list of objects from the bank. After clicking on one of the buttons, the customer will use one of the items in the list.
My question is the following: What would be the best way to get this object? Gives list I already have, or I make a new select in the bank?
@PostConstruct
public void init() {
int IdPaciente = Integer.parseInt(Str.NullToStrDef(FaceUtil.getRequest().getParameter("idpaciente"), "0"));
paciente = pacienteDao.find(IdPaciente);
listProgramas = programaDao.findByAplicador(loginController.getUsuarioLogado().getIdusuario(), IdPaciente);
int IdPrograma = Integer.parseInt(Str.NullToStrDef(FaceUtil.getRequest().getParameter("programa"), "0"));
if(IdPrograma > 0) {
programaAplicando = programaDao.find(IdPrograma); //Assim?
programaAplicando = listProgramas.stream()
.filter(t -> t.getIdprograma() == IdPrograma)
.collect(Collectors.toList()).get(0); //ou assim?
}
}
Cool Dilermando! It was +- what I had in mind, but I needed to know if it made "sense". One of the things I always worry about is not making requisitions to the bank unnecessarily. Regarding your suggestion, I really need to bring all the programs, since the user will "take" one of them to run. And since I use a Viewscoped, I don’t need to give another select. In this case, the program is not changed frequently, so I do not need to worry about data competition. ;)
– Alexandre Biancuzzi