JSF2.0 - Handling Ajax Error Calls Using Primefaces 3.0

I have commandButton on my .xhtml page:

 <p:commandButton action="#{someone.doSomething()}" ajax="true" onerror="errorDialog.show();"> </p:commandButton> 

It just makes an Ajax call. How can I detect situations such as an Internet connection problem (client / browser), timeout, session timeout, server-side exceptions, crashes, etc. In the middle of an Ajax call to show an informational message to the user?

Does the onerror p:ajax attribute onerror all of these? If not, then what? :) What is the default btw timeout value?

Any thanks, thanks.

+3
source share
1 answer

onerror calls this function:
onerror (xhr, status, exception) - Javascript callback to handle if the ajax request failed. It takes three arguments: xmlhttprequest, a status bar, and an exception, if any.
This information is taken from the documentation. xhr is actually a request. Thus, the status of the request and a lot of other information can be found.

 <p:commandButton action="#{someone.doSomething()}" ajax="true" onerror="console.debug(xhr)"> </p:commandButton> 

Try this code in chrome or firebug. It will show the xhr object

See the http://primefaces.googlecode.com/files/primefaces_users_guide_3_0.pdf section 7.2 Ajax API

+2
source

All Articles