Call Js Function Before Redirect
The situation is as follows: A user on the client side enters some data and presses a command button that initiates an ajax request. Depending on the input data the JSF Bean on the
Solution 1:
You need to redirect by JS instead of by JSF. Return null
from action method so that it returns to the same page and then execute the following script to perform a redirect in JS.
window.location = newURL;
Solution 2:
If you use PrimeFaces with JSF then it's possible to make global override of PrimeFaces.ajax.ResponseProcessor.doRedirect in javascript to put any custom code before actual redirect happens:
PrimeFaces.ajax.ResponseProcessor.doRedirect = function(node) {
// <<<< your code is here >>>>window.location = node.getAttribute('url');
}
Put this code in some js file and include it in all your pages.
Post a Comment for "Call Js Function Before Redirect"