RequestContext as null

3

I'm trying to update an on-screen component with RequestContext of primefaces . However there are 2 situations where the first one is I click on a link and the page gives its refresh. The second situation is where I have a scheduler on the system that calls a method often, at the end of this method I ask to update the component, then there is the problem because RequestContext arrives as null and I do not succeed, does anyone know how I can solve ?

RequestContext context = RequestContext.getCurrentInstance();
context.update("listaEncomendas:viewFull:cadastroEdicaoForm:atualizacao");
    
asked by anonymous 30.03.2017 / 01:32

1 answer

2

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

And if you used Ajax Poll from Primefaces:

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

In the example the poll will run automatically when you enter the page every

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

  • The autoStart property by default is true (executed automatically when you enter the page)

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

  • Your poll should be within a form

30.03.2017 / 02:06