JSF PostConstruct异常处理 - 重定向 [英] JSF PostConstruct Exception Handling - Redirect
问题描述
我想通过重定向到另一个页面来处理JSF @PostConstruct异常。我正在使用 FacesContext.getCurrentInstance()。getExternalContext()。dispatch(page.jsf);
这是非常好的,但是由于页面使用2个支持bean,它继续加载另一个支持bean(如果在其他支持bean上遇到错误,它将不会获得该调度/重定向)。我的问题是..有没有办法迫使调度立即发生,而不是加载所有其他东西?
I'd like to handle a JSF @PostConstruct exception by redirecting to another page. I'm using FacesContext.getCurrentInstance().getExternalContext().dispatch("page.jsf");
which works great but since the page uses 2 backing beans it continues to load the other backing bean (and if it encounters an error on the other backing bean it never gets to that dispatch/redirect). My question is.. is there a way to force that dispatch to happen right away and not load everything else?
推荐答案
这个类似的问题:
JSF导航重定向到上一页
根据BalusC,您可以使用以下代替调度:
According to BalusC you can use the following instead of dispatch:
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
或者,为了停止呈现当前页面,将
Or, in order to stop rendering the current page, put
FacesContext.getCurrentInstance().responseComplete();
关于
这篇关于JSF PostConstruct异常处理 - 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!