Author: abelevich
Date: 2007-07-30 09:58:37 -0400 (Mon, 30 Jul 2007)
New Revision: 1924
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/RichMessageBaseRenderer.java
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessageRenderer.java
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
Log:
new reviewed renders classes
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/RichMessageBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/RichMessageBaseRenderer.java
(rev 0)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/RichMessageBaseRenderer.java 2007-07-30
13:58:37 UTC (rev 1924)
@@ -0,0 +1,268 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.renderkit.html.HtmlRichMessageRenderer;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+
+public abstract class RichMessageBaseRenderer extends HeaderResourcesRendererBase{
+
+ protected static final Log log = LogFactory.getLog(HtmlRichMessageRenderer.class);
+
+ public static final String NULL_PARAMETER_ERROR_MESSAGE = "null parameter
ERROR";
+
+ public static final String COMPONENT_NOT_FOUND_IN_VIEW_WARN_MESSAGE = "component
not found in the view WARNING";
+
+
+ protected Iterator getMessageIterator(FacesContext context, String forClientId,
UIComponent component) throws IOException{
+
+ Iterator msgIter = null;
+
+ if(forClientId != null && forClientId.length() != 0){
+
+ UIComponent result = findForComponent(context, forClientId,component);
+ if (result == null) {
+ msgIter = CollectionUtils.EMPTY_COLLECTION.iterator();
+ } else {
+ msgIter = context.getMessages(result.getClientId(context));
+ }
+ }else{
+ msgIter = context.getMessages(null);
+ msgIter = context.getMessages();
+ }
+
+ return msgIter;
+ }
+
+ protected void renderMarkerFacet(UIComponent uiMsg, FacesContext context, ResponseWriter
writer,FacesMessage facesMsg) throws IOException{
+
+ UIComponent marker = null;
+
+ String markerClass = null;
+
+ String markerStyle = null;
+
+ Severity severity = null;
+
+
+ if(facesMsg != null){
+
+ severity = facesMsg.getSeverity();
+
+ if(severity == FacesMessage.SEVERITY_ERROR){
+
+ markerClass = (String)uiMsg.getAttributes().get("errorMarkerClass");
+ markerStyle = (String)uiMsg.getAttributes().get("errorMarkerStyle");
+ marker = uiMsg.getFacet("errorMarker");
+
+ }else if (severity == FacesMessage.SEVERITY_FATAL) {
+
+ markerClass = (String)uiMsg.getAttributes().get("fatalMarkerClass");
+ markerStyle = (String)uiMsg.getAttributes().get("fatalMarkerStyle");
+ marker = uiMsg.getFacet("fatalMarker");
+
+ }else if (severity == FacesMessage.SEVERITY_INFO) {
+
+ markerClass = (String)uiMsg.getAttributes().get("infoMarkerClass");
+ markerStyle = (String)uiMsg.getAttributes().get("infoMarkerStyle");
+ marker = uiMsg.getFacet("infoMarker");
+
+ }else if (severity == FacesMessage.SEVERITY_WARN) {
+
+ markerClass = (String)uiMsg.getAttributes().get("warnMarkerClass");
+ markerStyle = (String)uiMsg.getAttributes().get("warnMarkerStyle");
+ marker = uiMsg.getFacet("infoMarker");
+
+ }
+
+ }else if(uiMsg.getFacet("passedMarker") != null){
+
+ marker = uiMsg.getFacet("passedMarker");
+ markerClass = (String) uiMsg.getAttributes().get("markerClass");
+ markerStyle = (String) uiMsg.getAttributes().get("markerStyle");
+
+ }
+
+ if(marker == null){
+ return;
+ }
+
+ if(!marker.isRendered()){
+ return;
+ }
+
+ renderMarkerHtml(uiMsg, marker, context, writer, markerClass, markerStyle);
+ }
+
+ protected void renderLabel(UIComponent component, FacesContext context, ResponseWriter
writer,FacesMessage facesMsg) throws IOException{
+
+ String labelClass = null;
+
+ String labelStyle = null;
+
+ String passLabel = null;
+
+ Severity severity = null;
+
+
+ if(facesMsg != null){
+
+ severity = facesMsg.getSeverity();
+
+ if(severity == FacesMessage.SEVERITY_ERROR){
+
+ labelClass = (String)component.getAttributes().get("errorLabelClass");
+ labelStyle = (String)component.getAttributes().get("errorLabelStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_FATAL){
+
+ labelClass = (String)component.getAttributes().get("fatalLabelClass");
+ labelStyle = (String)component.getAttributes().get("fatalLabelStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_WARN){
+
+ labelClass = (String)component.getAttributes().get("warnLabelClass");
+ labelStyle = (String)component.getAttributes().get("warnLabelStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_INFO){
+
+ labelClass = (String)component.getAttributes().get("infoLabelClass");
+ labelStyle = (String)component.getAttributes().get("infoLabelStyle");
+
+ }
+
+ }else if(component.getAttributes().get("passedLabel") != null){
+
+ passLabel = (String) component.getAttributes().get("passedLabel");
+ labelClass = (String) component.getAttributes().get("labelClass");
+ labelStyle = (String) component.getAttributes().get("labelStyle");
+
+ }
+
+ renderLabelHtml(component, context, writer, facesMsg, labelClass, labelStyle,
passLabel);
+ }
+
+ protected void outerStyles(UIComponent component, FacesContext context, ResponseWriter
writer,FacesMessage facesMsg) throws IOException{
+
+ String outerClass = null;
+
+ String outerStyle = null;
+
+ Severity severity = null;
+
+
+ if(facesMsg != null){
+
+ severity = facesMsg.getSeverity();
+ if(severity == FacesMessage.SEVERITY_ERROR){
+
+ outerClass = (String)component.getAttributes().get("errorClass");
+ outerStyle = (String)component.getAttributes().get("errorStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_FATAL){
+
+ outerClass = (String)component.getAttributes().get("fatalClass");
+ outerStyle = (String)component.getAttributes().get("fatalStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_WARN){
+
+ outerClass = (String)component.getAttributes().get("warnClass");
+ outerStyle = (String)component.getAttributes().get("warnStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_INFO){
+
+ outerClass = (String)component.getAttributes().get("infoClass");
+ outerStyle = (String)component.getAttributes().get("infoStyle");
+ }
+ }
+
+ renderOuterStyles(component, context, writer, outerStyle, outerClass);
+
+ }
+
+ protected UIComponent findForComponent(FacesContext context, String forClientId,
UIComponent component) throws IOException{
+
+ if(null == forClientId || forClientId.length() == 0){
+ return null;
+ }
+
+ UIComponent result = null;
+ UIComponent parent = component;
+
+ while(parent != null){
+ result = parent.findComponent(forClientId);
+
+ if(result != null){
+ break;
+ }
+ parent = parent.getParent();
+ }
+
+ if(result == null){
+ result = findComponentBelow(context.getViewRoot(), forClientId);
+ }
+
+ if(result == null){
+ if(log.isWarnEnabled()){
+ log.warn(COMPONENT_NOT_FOUND_IN_VIEW_WARN_MESSAGE + ":"+ forClientId);
+ }
+ }
+
+ return result;
+ }
+
+ protected UIComponent findComponentBelow(UIComponent startComponent, String
forClientId){
+
+ UIComponent retComp = null;
+
+ if(startComponent.getChildCount() == 0){
+ return null;
+ }
+
+ List children = startComponent.getChildren();
+
+ for(int i = 0, size = children.size(); i < size; i++){
+ UIComponent comp = (UIComponent) children.get(i);
+
+ if(comp instanceof NamingContainer){
+ retComp = comp.findComponent(forClientId);
+ }
+
+ if(retComp == null){
+ if(comp.getChildCount() > 0){
+ retComp = findComponentBelow(comp, forClientId);
+ }
+ }
+
+ if(retComp != null)
+ break;
+ }
+
+ return retComp;
+ };
+
+ public abstract void renderMarkerHtml(UIComponent component, UIComponent markerFacet,
FacesContext context, ResponseWriter writer,
+ String markerClass, String markerStyle) throws IOException;
+
+ public abstract void renderLabelHtml(UIComponent component, FacesContext context,
ResponseWriter writer,
+ FacesMessage facesMsg, String labelClass, String labelStyle, String passLabel)
throws IOException;
+
+ public abstract void renderOuterStyles(UIComponent component, FacesContext context,
ResponseWriter writer, String outerStyle, String outerClass) throws IOException;
+}
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessageRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessageRenderer.java
(rev 0)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessageRenderer.java 2007-07-30
13:58:37 UTC (rev 1924)
@@ -0,0 +1,235 @@
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.UIRichMessage;
+import org.richfaces.renderkit.RichMessageBaseRenderer;
+
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class HtmlRichMessageRenderer extends RichMessageBaseRenderer{
+
+ private final InternetResource[] styles =
{getResource("/org/richfaces/renderkit/html/css/msg.css")};
+
+ private InternetResource[] stylesAll = null;
+
+
+ protected InternetResource[] getStyles(){
+ synchronized (this){
+ if(stylesAll == null){
+
+ InternetResource[] rsrcs = super.getStyles();
+ boolean ignoreSuper = rsrcs == null || rsrcs.length == 0;
+ boolean ignoreThis = styles == null || styles.length == 0;
+
+ if(ignoreSuper){
+
+ if (ignoreThis) {
+ stylesAll = new InternetResource[0];
+ } else {
+ stylesAll = styles;
+ }
+
+ }else{
+ if(ignoreThis){
+ stylesAll = rsrcs;
+ }else{
+ Set rsrcsSet = new java.util.LinkedHashSet();
+
+ for(int i = 0; i < rsrcs.length; i++ ){
+ rsrcsSet.add(rsrcs[i]);
+ }
+
+ for(int i = 0; i < styles.length; i++ ){
+ rsrcsSet.add(styles[i]);
+ }
+
+ stylesAll = (InternetResource[]) rsrcsSet.toArray(new
InternetResource[rsrcsSet.size()]);
+ }
+ }
+ }
+ }
+
+ return stylesAll;
+ }
+
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+
+ Iterator msgIter = null;
+
+ UIRichMessage msgComponent = (UIRichMessage)component;
+ String forClientId = msgComponent.getFor();
+
+ if(forClientId == null){
+
+ if(log.isInfoEnabled()){
+ log.info(NULL_PARAMETER_ERROR_MESSAGE);
+ }
+
+ }else{
+
+ msgIter = getMessageIterator(context, forClientId, msgComponent);
+ writer.startElement(HTML.SPAN_ELEM, msgComponent);
+ getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
msgComponent.getClientId(context));
+
+ if(!msgIter.hasNext() && msgComponent.isPassed()){
+
+ encodingUIContent(msgComponent, context, null);
+
+ }else if(msgIter.hasNext() ){
+
+ FacesMessage message = (FacesMessage)msgIter.next();
+ encodingUIContent(msgComponent, context, message);
+
+ }
+
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+ }
+
+ protected void encodingUIContent(UIRichMessage uiMsg, FacesContext context, FacesMessage
facesMsg) throws IOException{
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ outerStyles(uiMsg, context, writer, facesMsg);
+ renderMarkerFacet(uiMsg,context, writer,facesMsg);
+ renderLabel(uiMsg, context, writer, facesMsg);
+
+
+ }
+
+ public void renderOuterStyles(UIComponent component, FacesContext context,
ResponseWriter writer,String outerStyle, String outerClass) throws IOException{
+
+ UIRichMessage uiMsg = null;
+
+ if(!(component instanceof UIRichMessage)){
+ return;
+ }
+
+ uiMsg = (UIRichMessage)component;
+
+ String parentStyle = (String)uiMsg.getAttributes().get("style");
+ String parentClass = (String)uiMsg.getAttributes().get("styleClass");
+
+ String richMessageClass = "rich-message" + (null != outerClass ? (outerClass
+ " ") : "");
+ String richMessageStyle = (null != outerStyle ? outerStyle + " ," :
"");
+
+ parentStyle = parentStyle != null ? (richMessageStyle + parentStyle) :
richMessageStyle;
+ parentClass = parentClass != null ? (richMessageClass + parentClass) :
richMessageClass;
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, parentClass);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, parentStyle);
+ }
+
+ public void renderMarkerHtml(UIComponent component,UIComponent marker, FacesContext
context,
+ ResponseWriter writer,String markerClass, String markerStyle) throws
IOException{
+
+ UIRichMessage uiMsg = null;
+
+ if(!(component instanceof UIRichMessage)){
+ return;
+ }
+
+ uiMsg = (UIRichMessage)component;
+
+ writer.startElement(HTML.SPAN_ELEM, uiMsg);
+
+ String classes = markerClass == null ? "rich-message-marker" :
"rich-message-marker " + markerClass;
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, classes);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, markerStyle);
+
+ renderChild(context, marker);
+
+ writer.endElement(HTML.SPAN_ELEM);
+
+ }
+
+ public void renderLabelHtml(UIComponent component, FacesContext context, ResponseWriter
writer,
+ FacesMessage facesMsg, String labelClass, String labelStyle, String passLabel)
throws IOException{
+
+ String summary = null;
+
+ String detail = null;
+
+ String title = null;
+
+ UIRichMessage uiMsg = null;
+
+ if(!(component instanceof UIRichMessage)){
+ return;
+ }
+
+ uiMsg = (UIRichMessage)component;
+
+ boolean isTooltip = getUtils().isBooleanAttribute(uiMsg, "tooltip");
+
+ boolean showSummary = uiMsg.isShowSummary();
+
+ boolean showDetail = uiMsg.isShowDetail();
+
+
+ if(facesMsg != null){
+ summary = (null != (summary = facesMsg.getSummary())) ? summary : "";
+ detail = (null != (detail = facesMsg.getDetail())) ? detail : "";
+ }
+
+ String classes = labelClass == null ? "rich-message-label" :
"rich-message-label " + labelClass;
+
+ writer.startElement(HTML.SPAN_ELEM, uiMsg);
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE,classes);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, labelStyle);
+
+ if(facesMsg != null){
+ if(isTooltip){
+ title = (String) uiMsg.getAttributes().get("title");
+ if(title != null){
+ getUtils().writeAttribute(writer, HTML.title_ATTRIBUTE, title);
+ }else{
+ getUtils().writeAttribute(writer, HTML.title_ATTRIBUTE, summary);
+ }
+ }
+
+ if(showDetail){
+ writer.writeText(detail, null);
+ writer.writeText("\t", null);
+ }
+
+ if(showSummary){
+ writer.writeText(summary, null);
+ writer.writeText("\t", null);
+ }
+ }else {
+
+ if(passLabel != null){
+ writer.writeText(passLabel, null);
+ writer.writeText("\t", null);
+ }
+
+ }
+
+ writer.endElement(HTML.SPAN_ELEM);
+
+ }
+
+ protected Class getComponentClass() {
+
+ return UIMessage.class;
+ }
+}
+
\ No newline at end of file
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java
(rev 0)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/HtmlRichMessagesRenderer.java 2007-07-30
13:58:37 UTC (rev 1924)
@@ -0,0 +1,390 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIMessages;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.UIRichMessages;
+import org.richfaces.renderkit.RichMessageBaseRenderer;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class HtmlRichMessagesRenderer extends RichMessageBaseRenderer {
+
+ private boolean isWroteTable = false;
+
+ private boolean isIteratorLayout = false;
+
+ private final InternetResource[] styles =
{getResource("/org/richfaces/renderkit/html/css/msgs.css")};
+
+ private InternetResource[] stylesAll = null;
+
+
+ protected InternetResource[] getStyles(){
+
+ synchronized (this){
+
+ if(stylesAll == null){
+
+ InternetResource[] rsrcs = super.getStyles();
+ boolean ignoreSuper = rsrcs == null || rsrcs.length == 0;
+ boolean ignoreThis = styles == null || styles.length == 0;
+
+ if(ignoreSuper){
+
+ if (ignoreThis) {
+ stylesAll = new InternetResource[0];
+ } else {
+ stylesAll = styles;
+ }
+
+ }else{
+
+ if(ignoreThis){
+ stylesAll = rsrcs;
+ }else{
+
+ Set rsrcsSet = new java.util.LinkedHashSet();
+ for(int i = 0; i < rsrcs.length; i++ ){
+ rsrcsSet.add(rsrcs[i]);
+ }
+
+ for(int i = 0; i < styles.length; i++ ){
+ rsrcsSet.add(styles[i]);
+ }
+
+ stylesAll = (InternetResource[]) rsrcsSet.toArray(new
InternetResource[rsrcsSet.size()]);
+ }
+
+ }
+
+ }
+ }
+
+ return stylesAll;
+ }
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+
+ String forIds = null;
+
+ Iterator messagesIter = null;
+
+
+ UIRichMessages uiMessages = (UIRichMessages)component;
+
+ if(uiMessages.isGlobalOnly()){
+ forIds = "";
+ }
+
+ messagesIter = getMessageIterator(context, forIds, component);
+
+ renderComponentUI(writer, context, component, messagesIter);
+ }
+
+ public void renderComponentUI(ResponseWriter writer, FacesContext context, UIComponent
component, Iterator messagesIter) throws IOException{
+
+ String layout = null;
+
+ String var = null;
+
+
+
+ UIRichMessages uiMessages = (UIRichMessages)component;
+
+ layout = (String)uiMessages.getAttributes().get("layout");
+ if((layout != null) && (layout.equals("table"))){
+
+ writer.startElement("table", uiMessages);
+
+ getUtils().writeAttribute(writer, HTML.cellpadding_ATTRIBUTE, "0");
+ getUtils().writeAttribute(writer, HTML.cellspacing_ATTRIBUTE, "0");
+
+ renderComponentOuterStyles(uiMessages, context, writer);
+
+ writer.startElement("tbody", uiMessages);
+ isWroteTable = true;
+
+ }else if((layout != null) && (layout.equals("iterator"))){
+
+ var = (String)uiMessages.getAttributes().get("var");
+ if(var == null){
+ FacesException e = new FacesException(new IllegalArgumentException("var
attribute is not defined"));
+ throw e;
+ }
+
+ writer.startElement(HTML.SPAN_ELEM, uiMessages);
+
+ renderComponentOuterStyles(uiMessages, context, writer);
+
+ isIteratorLayout = true;
+
+ }else if((layout != null) && (layout.equals("list"))){
+
+ writer.startElement("dl", uiMessages);
+
+ renderComponentOuterStyles(uiMessages, context, writer);
+
+ }
+
+ getUtils().writeAttribute(writer,HTML.id_ATTRIBUTE ,uiMessages.getClientId(context));
+
+ if(log.isInfoEnabled()){
+ log.info("start render messages");
+ }
+
+ if(!messagesIter.hasNext()){
+
+ renderBody(uiMessages, context, writer, null);
+
+ }else{
+
+ while(messagesIter.hasNext()){
+
+ FacesMessage facesMsg = (FacesMessage)(messagesIter.next());
+
+ if(!isIteratorLayout){
+
+ renderBody(uiMessages, context, writer, facesMsg);
+
+ }else{
+
+ Map requestMap = context.getExternalContext().getRequestMap();
+ Object value = requestMap.get(var);
+ requestMap.put(var, facesMsg);
+
+ try {
+
+ if(log.isInfoEnabled()){
+ log.info("start render children of " + uiMessages.getClientId(context) +
" component");
+ }
+
+ renderChildren(context, uiMessages);
+ } finally {
+
+ if(value != null){
+ requestMap.put(var, value);
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ if(!isIteratorLayout){
+
+ if(isWroteTable){
+ writer.endElement("tbody");
+ writer.endElement("table");
+ }else{
+ writer.endElement("dl");
+ }
+
+ }else{
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ }
+
+ public void renderLabelHtml(UIComponent component, FacesContext context, ResponseWriter
writer,
+ FacesMessage facesMsg, String labelClass, String labelStyle, String passLabel)
throws IOException {
+
+ String summary = null;
+
+ String detail = null;
+
+ String title = null;
+
+ UIRichMessages uiMessages = null;
+
+
+ if(!(component instanceof UIRichMessages)){
+ return;
+ }
+
+ uiMessages = (UIRichMessages)component;
+
+ if(log.isInfoEnabled()){
+ log.info("start render label HTML");
+ }
+
+ boolean isTooltip = getUtils().isBooleanAttribute(uiMessages, "tooltip");
+
+ boolean showSummary = uiMessages.isShowSummary();
+
+ boolean showDetail = uiMessages.isShowDetail();
+
+ if(facesMsg != null){
+ summary = (null != (summary = facesMsg.getSummary())) ? summary : "";
+ detail = (null != (detail = facesMsg.getDetail())) ? detail : "";
+ }
+
+ labelClass = labelClass == null ? "rich-messages-label" :
"rich-messages-label " + labelClass;
+
+ if(isWroteTable){
+ writer.startElement(HTML.td_ELEM,uiMessages);
+ }
+
+ writer.startElement(HTML.SPAN_ELEM, uiMessages);
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE,labelClass);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, labelStyle);
+
+ if(facesMsg != null){
+
+ if(isTooltip){
+
+ title = (String) uiMessages.getAttributes().get("title");
+ if(title != null){
+ getUtils().writeAttribute(writer, HTML.title_ATTRIBUTE, title);
+ }else{
+ getUtils().writeAttribute(writer, HTML.title_ATTRIBUTE, summary);
+ }
+
+ }
+
+ if(showDetail){
+ writer.writeText(detail, null);
+ writer.writeText("\t", null);
+ }
+
+ if(showSummary){
+ writer.writeText(summary, null);
+ writer.writeText("\t", null);
+ }
+
+ }else {
+
+ if(passLabel != null){
+ writer.writeText(passLabel, null);
+ writer.writeText("\t", null);
+ }
+
+ }
+
+ writer.endElement(HTML.SPAN_ELEM);
+
+ if(isWroteTable){
+ writer.endElement(HTML.td_ELEM);
+ }
+ }
+
+ public void renderMarkerHtml(UIComponent component, UIComponent markerFacet,
FacesContext context,
+ ResponseWriter writer, String markerClass, String markerStyle)throws IOException
{
+
+ UIRichMessages uiMessages = null;
+
+ if(!(component instanceof UIRichMessages)){
+ return;
+ }
+
+ if(log.isInfoEnabled()){
+ log.info("start render marker HTML: " + markerFacet.getClientId(context));
+ }
+
+ uiMessages = (UIRichMessages)component;
+
+ if(isWroteTable){
+ writer.startElement(HTML.td_ELEM, uiMessages);
+ }else{
+ writer.startElement(HTML.SPAN_ELEM, uiMessages);
+ }
+
+ String classes = markerClass == null ? "rich-messages-marker" :
"rich-messages-marker " + markerClass;
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, classes);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, markerStyle);
+
+ renderChild(context, markerFacet);
+
+ if(isWroteTable){
+ writer.endElement(HTML.td_ELEM);
+ }else{
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ }
+
+ public void renderComponentOuterStyles(UIComponent component, FacesContext context,
ResponseWriter writer) throws IOException {
+
+ UIRichMessages uiMessages = null;
+
+ if(!(component instanceof UIRichMessages)){
+ return;
+ }
+
+ uiMessages = (UIRichMessages)component;
+
+ if(log.isInfoEnabled()){
+ log.info("start render component outer styles: " +
uiMessages.getClientId(context));
+ }
+
+ String parentStyle = (String)uiMessages.getAttributes().get("style");
+ String parentClass = (String)uiMessages.getAttributes().get("styleClass");
+
+ String richMessageClass = "rich-messages";
+
+ parentClass = parentClass != null ? (richMessageClass + " " + parentClass) :
richMessageClass;
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, parentClass);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, parentStyle);
+
+ }
+
+ public void renderOuterStyles(UIComponent component, FacesContext context,
ResponseWriter writer,
+ String outerStyle, String outerClass) throws IOException {
+
+ String richMessageClass = null != outerClass ? outerClass:"";
+ String richMessageStyle = (null != outerStyle ? outerStyle : "");
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, richMessageClass);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, richMessageStyle);
+
+ }
+
+ public void renderBody(UIRichMessages uiMessages, FacesContext context, ResponseWriter
writer,FacesMessage facesMsg) throws IOException{
+
+ if(uiMessages.isPassed()){
+
+ if(isWroteTable){
+ writer.startElement(HTML.TR_ELEMENT, uiMessages);
+ }else if(!isIteratorLayout){
+ writer.startElement("dt", uiMessages);
+ }
+
+ outerStyles(uiMessages, context, writer, facesMsg);
+ renderMarkerFacet(uiMessages, context, writer, facesMsg);
+ renderLabel(uiMessages, context, writer, facesMsg);
+
+ if(isWroteTable){
+ writer.endElement(HTML.TR_ELEMENT);
+ }else if(!isIteratorLayout){
+ writer.endElement("dt");
+ }
+
+ }
+
+ }
+
+ protected Class getComponentClass() {
+ return UIMessages.class;
+ }
+
+}