Announcement Announcement Module
Collapse
No announcement yet.
DelegatingPhaseListenerMulticaster should respect PhaseIds Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DelegatingPhaseListenerMulticaster should respect PhaseIds

    I like the DelegatingPhaseListenerMulticaster. But they dont respect the Phase-Id for the registered Phaselisteners!
    Here is a simple improvement ...

    Code:
    public class DelegatingPhaseListenerMulticaster implements PhaseListener {
    
    	public PhaseId getPhaseId() {
    		return PhaseId.ANY_PHASE;
    	}
    
            public void beforePhase(PhaseEvent event) {
    		Collection listeners = getDelegates(event.getFacesContext());
    		Iterator it = listeners.iterator();
    		while (it.hasNext()) {
    			PhaseListener listener = (PhaseListener) it.next();
                            
        PhaseId phaseId = event.getPhaseId();
        if (phaseId.equals(listener .getPhaseId()))
        {
          listener.beforePhase(event);
        }
    
    		}
    	}
    
    	public void afterPhase(PhaseEvent event) {
    		Collection listeners = getDelegates(event.getFacesContext());
    		Iterator it = listeners.iterator();
    		while (it.hasNext()) {
    			PhaseListener listener = (PhaseListener) it.next();
    
        PhaseId phaseId = event.getPhaseId();
        if (phaseId.equals(listener .getPhaseId()))
        {
          listener.afterPhase(event);
        }
    
    		}
    	}
    ...
    Regards
    Andreas
Working...
X