I'm trying to call a method periodically, but listner
of poll
does not call the method you want. Below my codes:
<p:poll interval="10" update=":listaEncomendas:viewFull:resultadoPendentes,msgAtualizacao"
listener="#{encomendaController.verificarAtualizacao()}" />
The controller:
@ManagedBean
@SessionScoped
public class EncomendaController implements Serializable {
public void verificarAtualizacao() throws Exception {
final List<Encomenda> encomendas = service.findAll();
if (CollectionUtils.isNotEmpty(encomendas)) {
for (Encomenda encomenda : encomendas) {
Encomenda encomendaAux = consultarEncomenda(encomenda.getCodigo());
if (encomendaAux.getEventos().size() > encomenda.getEventos().size()) {
encomendas.remove(encomenda);
atualizarEncomenda(encomenda, encomendaAux);
encomendas.add(encomenda);
service.atualizar(encomenda);
JsfUtils.enviarEmail(encomenda);
}
}
}
pesquisar(encomendas);
}
}
One note is that this started occurring after including the listner, updating things on the screen etc was working.