如何通过URL (在后台bean中)将用户重定向到portlet中的其他页面?我们在 5.1.0上使用JBoss GateIn 3.1
通常,FacesContext.getCurrentInstance().getExternalContext().redirect("url")就足够了,但是在这里它不能工作,它不能重定向用户。
context.getApplication().getNavigationHandler().handleNavigation(context, null, page)也不起作用。
我们希望避免为可以重定向到的每一个可能的页面制定导航规则。
编辑:a4j:commandButton似乎造成了一些问题,在我们用h:commandButton替换它之后,我们被重定向了,但不仅仅是在portlet内部,而是在门户中。
发布于 2013-12-18 07:41:16
我发现唯一的其他选择(在faces-config.xml中有很多导航用例)是使用FacesContext.getCurrentInstance().getViewRoot().setViewId(page)重定向,其中页面是String page = FacesContext.getCurrentInstance().getViewRoot().getViewId()。
发布于 2013-12-17 08:22:00
要使sendRedirect可用,必须将对象响应转换为HttpServletResponse:
HttpServletResponse objHttpServletResponse = (HttpServletResponse)
FacesContext.getCurrentInstance()
.getExternalContext()
.getResponse();
objHttpServletResponse.sendRedirect(url);这是一个302重定向,由浏览器管理。
https://stackoverflow.com/questions/20606786
复制相似问题