I am using JSF2/Primefaces and I was wondering how to implement a timeout callback either with jsf or primefaces ?
I want to make the timeout for the ajax request 30 seconds and if the request timed out do something as a callback .
I am using JSF2/Primefaces and I was wondering how to implement a timeout callback either with jsf or primefaces ?
I want to make the timeout for the ajax request 30 seconds and if the request timed out do something as a callback .
I put my foot where my mouth is and investigated the source and found a hint. Not to clear but a start so I did some quick Googling and one of the first hits was a PrimeFaces forum topic about setting the timeout
As a result of this (weird that I did not do that upfront), I opended the documentation and searched for timeout
. Lots of hits and it in the end turned out you could do
<p:ajax timeout="30000" ... />
<p:commandButton timeout="30000" ... />
etc... So it is already built in
For acting on the 'error' there is the onerror eventhandler which takes the name of a javascript function for basic ajax handling
<p:ajax timeout="30000" onerror="doMyErrorThing" ... />
<p:commandButton timeout="30000" onerror="doMyErrorThing"... />
function doMyErrorThing(...) {
// do your thing
}
To call a server-side method in that case call a p:remoteCommand
and all should be as you want it