While working on the product we came across a requirement where we need to
Refresh Current View without changing
View-Id
, So that we can preserve all view
scope beans from re-initialization.
Most Common Solution
Refresh Page by Reloading it, using faces redirect on same page. This fails in our case as redirect always ChangesView-Id
and we would like to preserve it.
Common Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); | |
ec.redirect(((HttpServletRequest) ec.getRequest()).getRequestURI()); |
Ajax Update using @all
Prime-Faces Component Library which supports Ajax update using@all
as a update all UI components,
but some how this was not giving us desired
results with few components like
Gmap, Data-Table etc.
The Solution is
After a lot of search and investigation we found a solution for this, I am writing same solution hoping this can help others as well.Final Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String refreshpage = context.getViewRoot().getViewId(); | |
ViewHandler handler = context.getApplication().getViewHandler(); | |
UIViewRoot root = handler.createView(context, refreshpage); | |
root.setViewId(refreshpage); | |
context.setViewRoot(root); |
Post a Comment
Post a Comment