public static void renderUnhandledMessages(FacesContext ctx) {
if (ctx.isProjectStage(ProjectStage.Development)) {
Application app = ctx.getApplication();
HtmlMessages messages = (HtmlMessages) app.createComponent(HtmlMessages.COMPONENT_TYPE);
messages.setId("javax_faces_developmentstage_messages");
Renderer messagesRenderer = ctx.getRenderKit().getRenderer(HtmlMessages.COMPONENT_FAMILY, "javax.faces.Messages");
messages.setErrorStyle("Color: red");
messages.setWarnStyle("Color: orange");
messages.setInfoStyle("Color: blue");
messages.setFatalStyle("Color: red");
messages.setTooltip(true);
messages.setTitle("Project Stage[Development]: Unhandled Messages");
messages.setRedisplay(false);
try {
messagesRenderer.encodeBegin(ctx, messages);
messagesRenderer.encodeEnd(ctx, messages);
} catch (IOException ioe) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE, ioe.toString(), ioe);
}
}
} else {
Iterator<String> clientIds = ctx.getClientIdsWithMessages();
int messageCount = 0;
if (clientIds.hasNext()) {
//Display each message possibly not displayed.
StringBuilder builder = new StringBuilder();
while (clientIds.hasNext()) {
String clientId = clientIds.next();
Iterator<FacesMessage> messages =
ctx.getMessages(clientId);
while (messages.hasNext()) {
FacesMessage message = messages.next();
if (message.isRendered()) {
continue;
}
messageCount++;
builder.append("\n");