* @param phaseId -
* phase, for which events must be processed.
*/
void broadcastEvents(FacesContext context, PhaseId phaseId) {
EventsQueue[] events = getEvents();
EventsQueue anyPhaseEvents = events[PhaseId.ANY_PHASE.getOrdinal()];
EventsQueue phaseEvents = events[phaseId.getOrdinal()];
if (phaseEvents.isEmpty() && anyPhaseEvents.isEmpty())
return;
// FacesEvent event = null;
boolean haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
boolean havePhaseEvents = !phaseEvents.isEmpty();
do {
// ANY_PHASE first
processEvents(context, anyPhaseEvents, haveAnyPhaseEvents);
processEvents(context, phaseEvents, havePhaseEvents);
// Events can queued in other events processing
haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
havePhaseEvents = !phaseEvents.isEmpty();
} while (haveAnyPhaseEvents || havePhaseEvents);
if (context.getRenderResponse() || context.getResponseComplete()) {
clearEvents();
}