private void broadcastEvents(FacesContext context, PhaseId phaseId) {
if (events == null) return;
for (FacesEvent event : new ArrayList<FacesEvent>(events)) {
PhaseId eventPhaseId = event.getPhaseId();
if (eventPhaseId.compareTo(PhaseId.ANY_PHASE) != 0 && eventPhaseId.compareTo(phaseId) != 0)
continue;
events.remove(event);
UIComponent source = event.getComponent();
try {
source.broadcast(event);