private boolean _broadcastAll ( FacesContext context , List < ? extends FacesEvent > events , Collection < FacesEvent > eventsAborted ) { assert events != null ; for ( int i = 0 ; i < events . size ( ) ; i ++ ) { FacesEvent event = events . get ( i ) ; UIComponent source = event . getComponent ( ) ; UIComponent compositeParent = UIComponent . getCompositeComponentParent ( source ) ; if ( compositeParent != null ) { pushComponentToEL ( context , compositeParent ) ; } // Push the source as the current component pushComponentToEL ( context , source ) ; try { // Actual event broadcasting if ( ! source . isCachedFacesContext ( ) ) { try { source . setCachedFacesContext ( context ) ; source . broadcast ( event ) ; } finally { source . setCachedFacesContext ( null ) ; } } else { source . broadcast ( event ) ; } } catch ( Exception e ) { Throwable cause = e ; AbortProcessingException ape = null ; do { if ( cause != null && cause instanceof AbortProcessingException ) { ape = ( AbortProcessingException ) cause ; break ; } cause = cause . getCause ( ) ; } while ( cause != null ) ; // for any other exception publish ExceptionQueuedEvent // publish the Exception to be handled by the ExceptionHandler // to publish or to not publish APE? That is the question : MYFACES-3199. We publish it, // because user can handle it in custom exception handler then. if ( ape != null ) { e = ape ; } ExceptionQueuedEventContext exceptionContext = new ExceptionQueuedEventContext ( context , e , source , context . getCurrentPhaseId ( ) ) ; context . getApplication ( ) . publishEvent ( context , ExceptionQueuedEvent . class , exceptionContext ) ; if ( ape != null ) { // APE found, abortion for this event only eventsAborted . add ( event ) ; } else { // We can't continue broadcast processing if other exception is thrown: return false ; } } finally { // Restore the current component source . popComponentFromEL ( context ) ; if ( compositeParent != null ) { compositeParent . popComponentFromEL ( context ) ; } } } return true ; }
Broadcast all events in the specified collection stopping the at any time an AbortProcessingException is thrown .