Pergunta

I have a JSF2 Primefaces page MultiAjax.xhtml with two buttons BUTA and BUTB. The page has a ViewScoped ManagedBean MBMultiAjax with two actionmethods butAAction and butBaction ... both methods have a startTime and endTime printed to sout ...

Both query the database and display the results in two different tables on the page.

If I press BUTA first and then BUTB, I find that the execution of the method butBaction begins after butAAction has finished and this is verified from the sout of starttime and endtime of both the methods ...

I expect that since Ajax is Asynchronous, the start time of the execution of both the methods must be just small difference and not Synchronous that one executed after the other.

Why is this happening?

Foi útil?

Solução

By default <p:commandButton will queue requests, you should add async attribute and set it to true :

<p:commandButton async="true" ... />

From Primefaces documentation :

async
Default: FALSE
Type: Boolean
Description: When set to true, ajax requests are not queued.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top