javax.faces.event.PhaseListener Java Examples

The following examples show how to use javax.faces.event.PhaseListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsfRequestLifecycleBroadcaster.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
protected void broadcastAfterEvent(PhaseEvent phaseEvent)
{
    //TODO discuss exception handling

    //fire to phase-observer methods
    this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), false)).fire(phaseEvent);
    this.afterAnyPhaseEvent.fire(phaseEvent);

    //fire to ds-phase-listeners
    //call the listeners in reverse-order (like jsf)
    ListIterator<PhaseListener> phaseListenerIterator = this.phaseListeners.listIterator(phaseListeners.size());

    while (phaseListenerIterator.hasPrevious())
    {
        PhaseListener phaseListener = phaseListenerIterator.previous();
        PhaseId targetPhase = phaseListener.getPhaseId();

        if (targetPhase == PhaseId.ANY_PHASE || targetPhase == phaseEvent.getPhaseId())
        {
            phaseListener.afterPhase(phaseEvent);
        }
    }
}
 
Example #2
Source File: JsfRequestLifecycleBroadcaster.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
protected void broadcastBeforeEvent(PhaseEvent phaseEvent)
{
    //TODO discuss exception handling

    //fire to phase-observer methods
    this.phaseEvent.select(createAnnotationLiteral(phaseEvent.getPhaseId(), true)).fire(phaseEvent);
    this.beforeAnyPhaseEvent.fire(phaseEvent);

    //fire to ds-phase-listeners
    for (PhaseListener phaseListener : this.phaseListeners)
    {
        PhaseId targetPhase = phaseListener.getPhaseId();

        if (targetPhase == PhaseId.ANY_PHASE || targetPhase == phaseEvent.getPhaseId())
        {
            phaseListener.beforePhase(phaseEvent);
        }
    }
}
 
Example #3
Source File: JsfRequestLifecycleBroadcaster.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Inject
protected JsfRequestLifecycleBroadcaster(Instance<PhaseListener> phaseListenerInstance)
{
    Class phaseListenerClass;
    for (PhaseListener currentPhaseListener : phaseListenerInstance)
    {
        phaseListenerClass = ProxyUtils.getUnproxiedClass(currentPhaseListener.getClass());

        if (phaseListenerClass.isAnnotationPresent(JsfPhaseListener.class))
        {
            if (Deactivatable.class.isAssignableFrom(phaseListenerClass) &&
                !ClassDeactivationUtils.isActivated(phaseListenerClass))
            {
                continue;
            }
            this.phaseListeners.add(currentPhaseListener);
        }
    }

    //higher ordinals first
    sortDescending(this.phaseListeners);
}
 
Example #4
Source File: CategorySelectionBean.java    From development with Apache License 2.0 6 votes vote down vote up
public PhaseListener getListener() {
    return new PhaseListener() {
        private static final long serialVersionUID = -66585096775189540L;

        public PhaseId getPhaseId() {
            return PhaseId.RENDER_RESPONSE;
        }

        public void beforePhase(PhaseEvent event) {
            unselectCategory();
        }

        public void afterPhase(PhaseEvent arg0) {
            // nothing
        }
    };
}
 
Example #5
Source File: JsfRequestLifecycleBroadcaster.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private static void sortDescending(List<PhaseListener> phaseListeners)
{
    Collections.sort(phaseListeners, new Comparator<PhaseListener>()
    {
        @Override
        public int compare(PhaseListener phaseListener1, PhaseListener phaseListener2)
        {
            return (phaseListener1.getClass().getAnnotation(JsfPhaseListener.class).ordinal() >
                    phaseListener2.getClass().getAnnotation(JsfPhaseListener.class).ordinal()) ? -1 : 1;
        }
    });
}
 
Example #6
Source File: MobileActionListener.java    From journaldev with MIT License 5 votes vote down vote up
public void listAllPhaseListeners() {
	LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
			.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
	Lifecycle applicationLifecycle = lifecycleFactory
			.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);

	PhaseListener phaseListeners[] = applicationLifecycle
			.getPhaseListeners();
	for (PhaseListener phaseListener : phaseListeners) {
		System.out.println(phaseListener.getPhaseId());
	}
}
 
Example #7
Source File: ExtValLifecycleFactory.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void addPhaseListener(PhaseListener listener) {
    if (firstPhaseListener) {
        //forced order independent of any other config
        firstPhaseListener = false;
        wrapped.addPhaseListener(new ExtValStartupListener());
    }
    wrapped.addPhaseListener(listener);
}
 
Example #8
Source File: MockLifecycle.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener phaseListener) {
}
 
Example #9
Source File: MockLifecycle.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public PhaseListener[] getPhaseListeners() {
	return null;
}
 
Example #10
Source File: UIViewRootStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void addPhaseListener(PhaseListener newPhaseListener) {
    throw new UnsupportedOperationException();
}
 
Example #11
Source File: UIViewRootStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener toRemove) {
    throw new UnsupportedOperationException();
}
 
Example #12
Source File: FacesContextServlet.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener listener) {
    throw new NotImplementedException();
}
 
Example #13
Source File: FacesContextServlet.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public PhaseListener[] getPhaseListeners() {
    throw new NotImplementedException();
}
 
Example #14
Source File: FacesContextServlet.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public void addPhaseListener(PhaseListener listener) {
    throw new NotImplementedException();
}
 
Example #15
Source File: ExtValLifecycleFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public PhaseListener[] getPhaseListeners() {
    return wrapped.getPhaseListeners();
}
 
Example #16
Source File: ExtValLifecycleFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener listener) {
    wrapped.removePhaseListener(listener);
}
 
Example #17
Source File: DeltaSpikeLifecycleWrapper.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public void addPhaseListener(PhaseListener phaseListener)
{
    this.wrapped.addPhaseListener(phaseListener);
}
 
Example #18
Source File: DeltaSpikeLifecycleWrapper.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public PhaseListener[] getPhaseListeners()
{
    return this.wrapped.getPhaseListeners();
}
 
Example #19
Source File: DeltaSpikeLifecycleWrapper.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener phaseListener)
{
    this.wrapped.removePhaseListener(phaseListener);
}
 
Example #20
Source File: MockLifecycle.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public PhaseListener[] getPhaseListeners() {
	return null;
}
 
Example #21
Source File: DelegatingPhaseListenerMulticaster.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void afterPhase(PhaseEvent event) {
	for (PhaseListener listener : getDelegates(event.getFacesContext())) {
		listener.afterPhase(event);
	}
}
 
Example #22
Source File: MockLifecycle.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void addPhaseListener(PhaseListener phaseListener) {
}
 
Example #23
Source File: MockLifecycle.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public PhaseListener[] getPhaseListeners() {
	return null;
}
 
Example #24
Source File: MockLifecycle.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener phaseListener) {
}
 
Example #25
Source File: DelegatingPhaseListenerMulticaster.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void beforePhase(PhaseEvent event) {
	for (PhaseListener listener : getDelegates(event.getFacesContext())) {
		listener.beforePhase(event);
	}
}
 
Example #26
Source File: DelegatingPhaseListenerMulticaster.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void afterPhase(PhaseEvent event) {
	for (PhaseListener listener : getDelegates(event.getFacesContext())) {
		listener.afterPhase(event);
	}
}
 
Example #27
Source File: MockLifecycle.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void addPhaseListener(PhaseListener phaseListener) {
}
 
Example #28
Source File: DelegatingPhaseListenerMulticaster.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void beforePhase(PhaseEvent event) {
	for (PhaseListener listener : getDelegates(event.getFacesContext())) {
		listener.beforePhase(event);
	}
}
 
Example #29
Source File: MockLifecycle.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void removePhaseListener(PhaseListener phaseListener) {
}
 
Example #30
Source File: DelegatingPhaseListenerMulticaster.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void beforePhase(PhaseEvent event) {
	for (PhaseListener listener : getDelegates(event.getFacesContext())) {
		listener.beforePhase(event);
	}
}