public static final String CLOSE_POPUP = "closePopup";
@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
UIMessages messages = (UIMessages) component;
if (messages.isConfirmation()) {
createPopup(facesContext, messages);
return;
}
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
if (LOG.isDebugEnabled()) {
LOG.debug("facesContext is " + facesContext.getClass().getName());
}
List<UIMessages.Item> messageList = messages.createMessageList(facesContext);
if (messageList.size() > 0) { // in ie empty span gets a height
writer.startElement(HtmlElements.SPAN, messages);
writer.writeClassAttribute(Classes.create(messages));
HtmlRendererUtils.writeDataAttributes(facesContext, writer, messages);
writer.writeStyleAttribute(new Style(facesContext, messages));
// with id
/*String focusId = null;
Iterator clientIds;
if (ComponentUtils.getBooleanAttribute(messages, Attributes.GLOBAL_ONLY)) {
ArrayList<String> list = new ArrayList<String>(1);
list.add(null);
clientIds = list.iterator();
} else {
clientIds = facesContext.getClientIdsWithMessages();
}*/
for (UIMessages.Item item : messageList) {
encodeMessage(writer, messages, item.getFacesMessage(), item.getClientId());
}
/*
while(clientIds.hasNext()) {
String clientId = (String) clientIds.next();
encodeMessagesForId(facesContext, writer, clientId, showSummary, showDetail);
if (focusId == null) {
focusId = clientId;
}
}
todo: don't forget: focus
if (focusId != null) {
ComponentUtils.findPage(facesContext, messages).setFocusId(focusId);
}
*/
writer.endElement(HtmlElements.SPAN);
if (messages.getFor() == null) {
String clientId = messages.getClientId(facesContext);
writer.startElement(HtmlElements.INPUT, null);
writer.writeAttribute(HtmlAttributes.VALUE, Boolean.TRUE.toString(), false);
writer.writeAttribute(HtmlAttributes.ID,
clientId + ComponentUtils.SUB_SEPARATOR + "messagesExists", false);
writer.writeAttribute(HtmlAttributes.NAME,
clientId + ComponentUtils.SUB_SEPARATOR + "messagesExists", false);
writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
writer.endElement(HtmlElements.INPUT);
}
}
if (messages.getFor() == null
&& !AjaxUtils.isAjaxRequest(facesContext)) {
AjaxInternalUtils.storeMessagesClientIds(facesContext, messages);
}
}