/** * Release the state context. * * @param facesContext the Faces context. */ public static void release(FacesContext facesContext) { StateContext stateContext = (StateContext) facesContext.getAttributes().get(KEY); UIViewRoot viewRoot = facesContext.getViewRoot(); if (viewRoot != null && stateContext.modListener != null) { viewRoot.unsubscribeFromViewEvent(PostAddToViewEvent.class, stateContext.modListener); viewRoot.unsubscribeFromViewEvent(PreRemoveFromViewEvent.class, stateContext.modListener); } facesContext.getAttributes().remove(KEY); }
/** * Release the state context. * * @param facesContext the Faces context. */ public static void release(FacesContext facesContext) { StateContext stateContext = (StateContext) facesContext.getAttributes().get(KEY); UIViewRoot viewRoot = facesContext.getViewRoot(); if (viewRoot != null && stateContext.modListener != null) { viewRoot.unsubscribeFromViewEvent(PostAddToViewEvent.class, stateContext.modListener); viewRoot.unsubscribeFromViewEvent(PreRemoveFromViewEvent.class, stateContext.modListener); } facesContext.getAttributes().remove(KEY); }
/** * Release the state context. * * @param facesContext the Faces context. */ public static void release(FacesContext facesContext) { StateContext stateContext = (StateContext) facesContext.getAttributes().get(KEY); UIViewRoot viewRoot = facesContext.getViewRoot(); if (viewRoot != null && stateContext.modListener != null) { viewRoot.unsubscribeFromViewEvent(PostAddToViewEvent.class, stateContext.modListener); viewRoot.unsubscribeFromViewEvent(PreRemoveFromViewEvent.class, stateContext.modListener); } facesContext.getAttributes().remove(KEY); }
/** * Release the state context. * * @param facesContext the Faces context. */ public static void release(FacesContext facesContext) { StateContext stateContext = (StateContext) facesContext.getAttributes().get(KEY); UIViewRoot viewRoot = facesContext.getViewRoot(); if (viewRoot != null && stateContext.modListener != null) { viewRoot.unsubscribeFromViewEvent(PostAddToViewEvent.class, stateContext.modListener); viewRoot.unsubscribeFromViewEvent(PreRemoveFromViewEvent.class, stateContext.modListener); } facesContext.getAttributes().remove(KEY); }
postAddToViewListeners = new ArrayList<SystemEventListener>(postAddToViewListeners); for (SystemEventListener l : postAddToViewListeners) { root.unsubscribeFromViewEvent(PostAddToViewEvent.class, l); preRemoveFromViewListeners = new ArrayList<SystemEventListener>(preRemoveFromViewListeners); for (SystemEventListener l : preRemoveFromViewListeners) { root.unsubscribeFromViewEvent(PreRemoveFromViewEvent.class, l);
@Test public void testRegisterDestructionCallback() { UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); doCallRealMethod().when(viewRoot).subscribeToViewEvent(any(), any()); doCallRealMethod().when(viewRoot).unsubscribeFromViewEvent(any(), any()); when(viewRoot.getViewListenersForEventClass(any())).thenCallRealMethod(); this.viewScope.registerDestructionCallback(KEY, () -> { }); this.viewScope.remove(KEY); }