JSF PostConstruct Exception Handling - Redirect

假装没事ソ 提交于 2019-12-01 05:51:54

问题


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?


回答1:


Look at this similar question: JSF navigation redirect to previous page

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();

Regards



来源:https://stackoverflow.com/questions/6208037/jsf-postconstruct-exception-handling-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!