void convert(@Observes @Before @RenderResponse final PhaseEvent event, Messages messages) {
Set<Message> savedMessages = (Set<Message>) context.get(FLASH_MESSAGES_KEY);
if (savedMessages != null) {
for (Message m : savedMessages) {
event.getFacesContext().addMessage(m.getTargets(),
new FacesMessage(getSeverity(m.getLevel()), m.getText(), null));
}
}
for (Message m : messages.getAll()) {
event.getFacesContext().addMessage(m.getTargets(), new FacesMessage(getSeverity(m.getLevel()), m.getText(), null));
}
messages.clear();
}