Requestcontext as null

Asked

Viewed 69 times

3

I’m trying to update a component on the screen by RequestContext of primefaces. But there are 2 situations where the first one is I click on a link and the page give your refresh. The second 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, here is the problem because the Requestcontext arrives as null and I am not successful, someone knows how I can solve ?

RequestContext context = RequestContext.getCurrentInstance();
context.update("listaEncomendas:viewFull:cadastroEdicaoForm:atualizacao");
  • You are running this method in your scheduler?

  • If your scheduler has the function of updating a jsf component you can consider using an ajax Poll that makes scheduled updates in addition to having an easy control of the beginning and end of the execution https://www.primefaces.org/showcase/ui/ajax/poll.xhtml

  • @The scheduler has a method that calls my method in question.

  • Your Requestcontext will not be available because your scheduler is not a Managed Bean.

  • 1

    Thank you, the poll worked.

1 answer

2


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

And if you used the Ajax Poll of Primefaces:

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

In the example the Poll will be executed automatically when entering the page each

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

  • The Autostart property by default is true (automatically executed when entering the page)

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

  • Your Poll must be inside a form

Browser other questions tagged

You are not signed in. Login or sign up in order to post.