RenderKit renderKit = getRenderKit(); FacesContext facesContext = getCurrentFacesContext(); if (renderKit == null)
@Override public boolean isPostback() { assertNotReleased(); RenderKit renderKit = getRenderKit(); if (renderKit == null) { // NullPointerException with StateManager, because // to restore state it first restore structure, // then fill it and in the middle of the two previous // process there is many calls from _ComponentChildrenList.childAdded // to facesContext.isPostback, and getViewRoot is null. // // Setting a "phantom" UIViewRoot calling facesContext.setViewRoot(viewRoot) // to avoid it is bad, because this is work of RestoreViewExecutor, // and theorically ViewHandler.restoreView must return an UIViewRoot // instance. // // The problem with this is if the user changes the renderkit directly // using f:view renderKitId param, the ResponseStateManager returned // will be the one tied to faces-config selected RenderKit. But the usual // method to check if a request is a postback, is always detect the param // javax.faces.ViewState, so there is no problem after all. String renderKitId = this.getApplication().getViewHandler().calculateRenderKitId(this); RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); renderKit = factory.getRenderKit(this, renderKitId); } return renderKit.getResponseStateManager().isPostback(this); }
@Override public boolean isPostback() { assertNotReleased(); RenderKit renderKit = getRenderKit(); if (renderKit == null) { // NullPointerException with StateManager, because // to restore state it first restore structure, // then fill it and in the middle of the two previous // process there is many calls from _ComponentChildrenList.childAdded // to facesContext.isPostback, and getViewRoot is null. // // Setting a "phantom" UIViewRoot calling facesContext.setViewRoot(viewRoot) // to avoid it is bad, because this is work of RestoreViewExecutor, // and theorically ViewHandler.restoreView must return an UIViewRoot // instance. // // The problem with this is if the user changes the renderkit directly // using f:view renderKitId param, the ResponseStateManager returned // will be the one tied to faces-config selected RenderKit. But the usual // method to check if a request is a postback, is always detect the param // javax.faces.ViewState, so there is no problem after all. String renderKitId = this.getApplication().getViewHandler().calculateRenderKitId(this); RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); renderKit = factory.getRenderKit(this, renderKitId); } return renderKit.getResponseStateManager().isPostback(this); }