There were couple of situations to redirect to a page in adf applications like from adf filter we need to redirect or on button click we need to redirect . Frank has posted a blog post in which he has mentioned how efficiently we can redirect to page. But the solution is working only in weblogic but not in glassfish.
You can find Frank's post here.
https://blogs.oracle.com/jdeveloperpm/how-to-efficiently-redirect-to-an-adf-faces-view-using-adf-controller
Case1. Redirect to a page from ADF Filter.
By using the request dispatcher we can redirect by using the following piece of code.
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse res = (HttpServletResponse) servletResponse;
if(username==null){
((HttpServletRequest)req).getRequestDispatcher("/faces/Pages/Login.jspx").forward(req, res);
}
}
Case2. Redirect to page on button click.
By using the ExtendedRenderKitService we can redirect to a page on button click.
String serverPath ="http://"+request.getServerName()+":"+request.getServerPort()+"/ApplicationName/faces/Pages/Home.jspx";
String url = "window.open('"+serverPath+"','_self');";
erks.addScript(FacesContext.getCurrentInstance(), url);
It will redirect to the page specified.
You can find Frank's post here.
https://blogs.oracle.com/jdeveloperpm/how-to-efficiently-redirect-to-an-adf-faces-view-using-adf-controller
Case1. Redirect to a page from ADF Filter.
By using the request dispatcher we can redirect by using the following piece of code.
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse res = (HttpServletResponse) servletResponse;
if(username==null){
((HttpServletRequest)req).getRequestDispatcher("/faces/Pages/Login.jspx").forward(req, res);
}
}
Case2. Redirect to page on button click.
By using the ExtendedRenderKitService we can redirect to a page on button click.
String serverPath ="http://"+request.getServerName()+":"+request.getServerPort()+"/ApplicationName/faces/Pages/Home.jspx";
String url = "window.open('"+serverPath+"','_self');";
erks.addScript(FacesContext.getCurrentInstance(), url);
It will redirect to the page specified.
No comments:
Post a Comment