Tuesday, November 4, 2014

How to perform Redirect in ADF using Managed Bean ?

This blog explains various ways to perform redirect in ADF using Managed bean


Approach 1

FacesContext fcx =FacesContext.getCurrentInstance()
fcx.responseComplete();
fcx.getApplication().getNavigationHandler().handleNavigation(fcx, null, "gotoHomePage");  
fcx.renderResponse();

Approach 2

fcx.responseComplete();  
fcx.getExternalContext().redirect(getServletRequest().getContextPath() + "/pages/HomePage.jspx");

Approach 3

RequestDispatcher dispatcher = getServletRequest().getRequestDispatcher("HomePage.jspx");
dispatcher.forward(getServletRequest(), getServletResponse());

Approach 4
getServletResponse().sendRedirect("gotoHomePage.jspx")