@Test public void beforeAndAfterPhaseWithSingleTarget() { TestListener target = new TestListener(); beanFactory.addBean("testListener", target); assertEquals(PhaseId.ANY_PHASE, delPhaseListener.getPhaseId()); PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle()); delPhaseListener.beforePhase(event); assertTrue(target.beforeCalled); delPhaseListener.afterPhase(event); assertTrue(target.afterCalled); }
@Test public void beforeAndAfterPhaseWithMultipleTargets() { TestListener target1 = new TestListener(); TestListener target2 = new TestListener(); beanFactory.addBean("testListener1", target1); beanFactory.addBean("testListener2", target2); assertEquals(PhaseId.ANY_PHASE, delPhaseListener.getPhaseId()); PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle()); delPhaseListener.beforePhase(event); assertTrue(target1.beforeCalled); assertTrue(target2.beforeCalled); delPhaseListener.afterPhase(event); assertTrue(target1.afterCalled); assertTrue(target2.afterCalled); }
protected PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId, Lifecycle lifecycle) { return new PhaseEvent(context, phaseId, lifecycle); }
protected void fireAfterPhase(final PhaseId phaseId) { phaseEventBridge.afterPhase(new PhaseEvent(facesContext, phaseId, lifecycle)); } }
protected void fireBeforePhase(final PhaseId phaseId) { phaseEventBridge.beforePhase(new PhaseEvent(facesContext, phaseId, lifecycle)); }
private PhaseEvent createEvent(FacesContext context, PhaseId phaseId) { if (_lifecycle == null) { LifecycleFactory factory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String id = context.getExternalContext().getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (id == null) { id = LifecycleFactory.DEFAULT_LIFECYCLE; } _lifecycle = factory.getLifecycle(id); } return new PhaseEvent(context, phaseId, _lifecycle); }
private void updateModelValuesPhase() throws Exception { phases.beforePhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE)); try { updateConversationId(); updateModelValues(); updateConversationId(); } finally { phases.afterPhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE)); } }
private void applyRequestValuesPhase() throws Exception { phases.beforePhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE)); try { updateConversationId(); applyRequestValues(); updateConversationId(); } finally { phases.afterPhase(new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE)); } }
private static PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId) throws FacesException { if (lifecycle == null) { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String lifecycleId = context.getExternalContext() .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (lifecycleId == null) { lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE; } lifecycle = lifecycleFactory.getLifecycle(lifecycleId); } return (new PhaseEvent(context, phaseId, lifecycle)); }
private PhaseEvent createEvent(FacesContext context, PhaseId phaseId) { if (_lifecycle == null) { LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String id = context.getExternalContext().getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (id == null) { id = LifecycleFactory.DEFAULT_LIFECYCLE; } _lifecycle = factory.getLifecycle(id); } return new PhaseEvent(context, phaseId, _lifecycle); }
private static PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId) throws FacesException { if (lifecycle == null) { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String lifecycleId = context.getExternalContext() .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (lifecycleId == null) { lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE; } lifecycle = lifecycleFactory.getLifecycle(lifecycleId); } return (new PhaseEvent(context, phaseId, lifecycle)); }
private static PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId) throws FacesException { if (lifecycle == null) { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String lifecycleId = context.getExternalContext() .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (lifecycleId == null) { lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE; } lifecycle = lifecycleFactory.getLifecycle(lifecycleId); } return (new PhaseEvent(context, phaseId, lifecycle)); }
private static PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId) throws FacesException { if (lifecycle == null) { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String lifecycleId = context.getExternalContext() .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (lifecycleId == null) { lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE; } lifecycle = lifecycleFactory.getLifecycle(lifecycleId); } return (new PhaseEvent(context, phaseId, lifecycle)); }
private static PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId) throws FacesException { if (lifecycle == null) { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); String lifecycleId = context.getExternalContext() .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR); if (lifecycleId == null) { lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE; } lifecycle = lifecycleFactory.getLifecycle(lifecycleId); } return (new PhaseEvent(context, phaseId, lifecycle)); }
public static void notifyBeforeListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) { PhaseEvent beforePhaseEvent = new PhaseEvent(context, phaseId, lifecycle); for (int i = 0; i < lifecycle.getPhaseListeners().length; i++) { PhaseListener listener = lifecycle.getPhaseListeners()[i]; if (listener.getPhaseId() == phaseId || listener.getPhaseId() == PhaseId.ANY_PHASE) { listener.beforePhase(beforePhaseEvent); } } }
public static void notifyBeforeListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) { PhaseEvent beforePhaseEvent = new PhaseEvent(context, phaseId, lifecycle); for (int i = 0; i < lifecycle.getPhaseListeners().length; i++) { PhaseListener listener = lifecycle.getPhaseListeners()[i]; if (listener.getPhaseId() == phaseId || listener.getPhaseId() == PhaseId.ANY_PHASE) { listener.beforePhase(beforePhaseEvent); } } }
public static void notifyAfterListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) { PhaseEvent afterPhaseEvent = new PhaseEvent(context, phaseId, lifecycle); for (int i = 0; i < lifecycle.getPhaseListeners().length; i++) { PhaseListener listener = lifecycle.getPhaseListeners()[i]; if (listener.getPhaseId() == phaseId || listener.getPhaseId() == PhaseId.ANY_PHASE) { listener.afterPhase(afterPhaseEvent); } } }
public static void notifyAfterListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) { PhaseEvent afterPhaseEvent = new PhaseEvent(context, phaseId, lifecycle); for (int i = (lifecycle.getPhaseListeners().length - 1); i >= 0; i--) { PhaseListener listener = lifecycle.getPhaseListeners()[i]; if (listener.getPhaseId() == phaseId || listener.getPhaseId() == PhaseId.ANY_PHASE) { listener.afterPhase(afterPhaseEvent); } } }
public static void notifyBeforeListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) { PhaseEvent beforePhaseEvent = new PhaseEvent(context, phaseId, lifecycle); for (int i = 0; i < lifecycle.getPhaseListeners().length; i++) { PhaseListener listener = lifecycle.getPhaseListeners()[i]; if (listener.getPhaseId() == phaseId || listener.getPhaseId() == PhaseId.ANY_PHASE) { listener.beforePhase(beforePhaseEvent); } } }
public static void notifyAfterListeners(PhaseId phaseId, Lifecycle lifecycle, FacesContext context) { PhaseEvent afterPhaseEvent = new PhaseEvent(context, phaseId, lifecycle); for (int i = (lifecycle.getPhaseListeners().length - 1); i >= 0; i--) { PhaseListener listener = lifecycle.getPhaseListeners()[i]; if (listener.getPhaseId() == phaseId || listener.getPhaseId() == PhaseId.ANY_PHASE) { listener.afterPhase(afterPhaseEvent); } } }