1
votes

I have a xhtml page where I have some primefaces component poll, blockui and commandbutton, when I click in this button I save something and start a async process and the same page I need block a panel (I use blockui component) and every 5 second I need to verify if this process finished.

I need to unblock this panel when my process finish but I have some problems with components. It follows my code

<p:blockUI id="blcInformacao" block="pnlInformacao" widgetVar="blockInformacao" blocked="#{cadastroCampanhaController.processando}" />
<p:poll interval="5" listener="#{cadastroCampanhaController.atualizarInformacaoImmportacao}" rendered="#{cadastroCampanhaController.campanha.codigo ne null}" stop="#{cadastroCampanhaController.campanha.importacaoFim ne null}" immediate="true" update="pnlImportacao btnSalvar " widgetVar="pollImportacao" autoStart="true" />
<p:commandButton id="btnSalvar" actionListener="#{cadastroCampanhaController.salvar}" value="SALVAR" update="@form" process="@this txtNome txtValidadeInicio txtValidadeFim rdDias txtStatus cmbFila txtScript" disabled="#{cadastroCampanhaController.processando}"/>
1
Can you describe exactly what the problem is? What are you expecting versus what you're observing - kolossus
I've found the solution, I used RequestContext.getCurrentInstance().execute("PF('blockInformacao').hide()"); in my ManagedBean - Alisson Vieira

1 Answers

0
votes

My solution:

In your poll component:

<p:poll id="poll" interval="10" listener="#{Bean.yourMethodBean}" update=":form:tableServico" onstart="PF('block').show()" oncomplete="PF('block').hide()">
            </p:poll>

Create a panel and inside your datatable

<p:outputPanel id="pnldatatable" >
   <p:dataTable id="tableServico" >
     YourColumns
   </p:dataTable>
</p:outputPanel>

The p:blockUI component, set atribute block for panel id, in this case pnldatatable:

<p:blockUI  block="pnldatatable" widgetVar="block" >
        LOADING<br />
        <p:graphicImage library="img" name="loader.gif"/>
  </p:blockUI>

Block("PF('block').show()") and Unblock("PF('block').hide()") my blockUI component with widgetVar object, in onstart and oncomplete events for poll component.