*
*/
public class HtmlRichMessagesRenderer extends RichMessageBaseRenderer {
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
UIRichMessages uiMessages = (UIRichMessages)component;
String layout = null;
String forIds = null;
String forClientId = uiMessages.getFor();
if(null != forClientId){
forIds = forClientId;
}
if(uiMessages.isGlobalOnly()){
if(null == forClientId){
forIds = "";
}else{
throw new FacesException("The rich:messages component must specify only one of 'for' or 'globalOnly' atribbute");
}
}
Iterator<FacesMessage> messagesIter = getMessageIterator(context, forIds, component);
boolean isDisplayNone = !messagesIter.hasNext();
String [] levels = uiMessages.getLevel().split(",");
List<String> acceptLevels = creatAcceptLevels(levels);
if(!isDisplayNone){
if (!isAcceptableMessagesPresent(acceptLevels, messagesIter)) {
isDisplayNone = true;
}
}
boolean isWroteTable = false;
layout = (String)uiMessages.getAttributes().get("layout");
if((layout != null) && (layout.equals("table"))){
writer.startElement("table", uiMessages);
getUtils().writeAttribute(writer,HTML.id_ATTRIBUTE ,uiMessages.getClientId(context));
getUtils().writeAttribute(writer, HTML.cellpadding_ATTRIBUTE, "0");
getUtils().writeAttribute(writer, HTML.cellspacing_ATTRIBUTE, "0");
renderComponentOuterStyles(uiMessages, context, writer, isDisplayNone);
writer.startElement("tbody", uiMessages);
isWroteTable = true;
}else if((layout != null) && (layout.equals("list"))){
isWroteTable = false;
writer.startElement("dl", uiMessages);
getUtils().writeAttribute(writer,HTML.id_ATTRIBUTE ,uiMessages.getClientId(context));
renderComponentOuterStyles(uiMessages, context, writer, isDisplayNone);
}
messagesIter = getMessageIterator(context, forIds, component);