I'm using Omnifaces FullAjaxExceptionHandler - which is working great, but when I do an ajax call and have an onevent function that is checking for status == 'success' it is still being called, even though the FullAjaxExceptionHandler has rendered an error page. (I'm using JSF(Mojarra 2.1.3 on glassfish 3.1.1)
JSF Code:
<h:commandButton value="myButton">
<f:ajax listener="#{myBean.myBeanFunction()}"
render="someDiv"
onevent="myFunction"/>
</h:commandButton>
Javascript Code:
function myFunction(e)
{
if (e.status == 'success') {
alert("Success");
}
}
So I need some way of not executing the javascript function if the FullAjaxExceptionHandler is taking me to an error page.
You could check as follows if the returned XML response does not indicate that a render="@all" has been performed (which would indicate that the entire document will be replaced):
if (e.responseXML.getElementById('javax.faces.ViewRoot') == null) {
// ...
}
That it works with oncomplete of a PrimeFaces command component is because it does not use the standard JSF ajax API for this and does things thus differently -more intuitively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With