In a PhaseListener, first get all the clientId(s) with queued messages, then try to find the components. But ViewRoot.findComponent(clientId) return null.
public void beforePhase(PhaseEvent event) {
FacesContext context = event.getFacesContext();
UIViewRoot root = context.getViewRoot();
Iterator<String> itr = context.getClientIdsWithMessages();
while (itr.hasNext()) {
String clientId = itr.next();
UIComponent component = root.findComponent(clientId);
UIViewRoot root = context.getViewRoot();
Iterator<String> itr = context.getClientIdsWithMessages();
while (itr.hasNext()) {
String clientId = itr.next();
UIComponent component = root.findComponent(clientId);
// ERROR: component is null
....
}
}
Thanks for ideas.
Relax. Yahoo! Mail virus scanning helps detect nasty viruses!