Created
January 2, 2013 09:01
-
-
Save neuro-sys/4433173 to your computer and use it in GitHub Desktop.
Ajax DataTable Pager fix through PhaseListener for JSF.
This file contains hidden or 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
| public void beforePhase(PhaseEvent event) { | |
| if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) { | |
| FacesContext facesContext = event.getFacesContext(); | |
| restoreMessages(facesContext); | |
| makeResponseCompatible(event); | |
| UIComponent root = facesContext.getViewRoot(); | |
| try { findPagerComponentAndReset(root); } catch(Exception e) {} | |
| } | |
| } | |
| private void findPagerComponentAndReset(UIComponent root) throws Exception { | |
| Iterator kids = root.getFacetsAndChildren(); | |
| while (kids.hasNext()) { | |
| Object o = kids.next(); | |
| if (o instanceof DataTable) { | |
| DataTable dt = (DataTable) o; | |
| dt.setFirst(0); | |
| System.out.println(dt.getId() + ": Pager reset."); | |
| } | |
| findPagerComponentAndReset((UIComponent) o); | |
| } | |
| return; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment