Friday, July 29, 2011

ADF page refresh using java code


This post will show the code for a full page refresh. Most of the time Partial page rendering do the work, still we need a full page refresh. For this easy way is to call a java method and refresh the page. This is needed when there is a change in database values and you want to refresh the form and table after operation. 

So use following code for this:
public void refresh() {
      FacesContext facesContext = FacesContext.getCurrentInstance();
      String refreshpage = facesContext.getViewRoot().getViewId();
 ViewHandler  viewHandler =
facesContext.getApplication().getViewHandler();
      UIViewRoot viewroot =  viewHandler.createView( facesContext, refreshpage);
viewroot.setViewId(refreshpage);
facesContext.setViewRoot(viewroot);
}

1 comment:

  1. Hi Rohit,
    i've used this but this works somehow different from F5 (classical reload). What is the difference between this two refresh methods? I need this to refresh an image via a servlet.

    ReplyDelete