The problem you will have with what you're planning is that a single component can have more than one message queued. What are you going to do then? For demonstration purposes, you can use
EDIT : You should just move the logic into your backing bean:
Implement a method that'll pull the detail from an available FacesMessage
list, given a clientId
public String getComponentMessageDetail(String clientId) {
String detail = null;
FacesContext ctxt = FacesContext.getCurrentInstance();
List componentMessages = ctxt.getMessages(clientId);
if (componentMessages != null && componentMessages.isEmpty() == false) {
//returns the detail, from only the first message!
detail = componentMessages.get(0).getDetail();
}
return detail;
}
Use the utility method in your view