
Untitled
By: a guest on
Jun 9th, 2012 | syntax:
None | size: 0.82 KB | hits: 21 | expires: Never
JSF 2.0 redirect error
@Named
@RequestScoped
public class LogoutBean implements Serializable
{
public void preRenderView(ComponentSystemEvent e)
{
userSessionBean.logout();
FacesContext ctx = FacesContext.getCurrentInstance();
try
{
ctx.getApplication().getNavigationHandler().handleNavigation(ctx, null, "/pages/index?faces-redirect=true");
}
catch (IllegalStateException exc)
{
// Ignore. This exception is caused by redirecting after the response is already committed. The redirect works anyway.
}
}
@Inject
private UserSessionBean userSessionBean;
}
public void preRenderView(ComponentSystemEvent e) throws IOException {
FacesContext.getCurrentInstance().getExternalContext().redirect("pages/index.xhtml");
}