java – RequestContext como null


I'm trying to update a component on the canvas via primefaces RequestContext . But there are 2 situations where the first is I click on a link and the page refreshes. The 2nd situation is where I have a scheduler in the system that calls a method frequently, at the end of this method I ask to update the component, there's the problem because the RequestContext arrives as null and I'm not successful, does anyone know how I can solve it ?

RequestContext context = RequestContext.getCurrentInstance();


Your RequestContext will not be available as your scheduler is not a ManagedBean.

And if you used Primefaces Ajax Poll:

    <p:poll interval="3" listener="#{seuBean.funcao()}" update="id_elemento_atualizar" />

In the example, the poll will be performed automatically when you enter the page every

  • A new run will be done every 3 seconds (interval)

  • The autoStart property by default is true (runs automatically when entering the page)

  • Until you run a javascript command to stop the poll it will keep running

  • Your poll must be inside a form.

Scroll to Top