Saturday, June 23, 2012

How to reload whole jsf/jspx page from bean in JDeveloper 11g ?

Oracle JDeveloper
ADF Faces Rich Components

Sometimes requirement is to refresh whole jspx page from root . By simple java bean code this can achieve.
 public String refreshPage_action() {  
    FacesContext fctx = FacesContext.getCurrentInstance();  
    String pageToRefresh = fctx.getViewRoot().getViewId();   //getting View Id of current page  
    ViewHandler viewHandler = fctx.getApplication().getViewHandler();      
    UIViewRoot viewRoot = viewHandler.createView(fctx, pageToRefresh);   //ViewRoot for current page  
    fctx.setViewRoot(viewRoot);     //set the viewroot in facesContext to reload  
    return null;