Primefaces:当onbeforeunload处于活动状态时处理重定向

时间:2013-09-23 08:58:01

标签: jsf-2 primefaces onbeforeunload

我在我的代码中的许多地方使用JSF重定向:

FacesContext.getCurrentInstance().getExternalContext().redirect(url);

重定向将在响应中发送:

<partial-response>
    <redirect url="http://some/url"></redirect>
</partial-response>

问题是,我有活动onbeforeunload并且在处理重定向时显示警告消息:

$(window).bind('beforeunload', function(){
    return '${onbeforeunload}';
});

有没有办法插入重定向处理机制并在该位置停用onbeforeunload?或者是否有任何JSF2 / PrimeFaces模式以通用方式处理onbeforeunload?

1 个答案:

答案 0 :(得分:0)

您可以尝试覆盖重定向功能PrimeFaces.ajax.ResponseProcessor.doRedirect(a),以便在重定向之前删除 beforeunload 侦听器。 jQuery.unbind