Author: abelevich
Date: 2007-07-23 10:21:15 -0400 (Mon, 23 Jul 2007)
New Revision: 1786
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java
Modified:
trunk/sandbox/ui/message/src/main/config/component/message.xml
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msg.css
Log:
Code review and new new span based mockup
Modified: trunk/sandbox/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-23 14:20:09 UTC
(rev 1785)
+++ trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-23 14:21:15 UTC
(rev 1786)
@@ -18,9 +18,10 @@
<![CDATA[ richfaces Message Component ]]>
</description>
- <renderer generate="true" override="true">
- <name>org.richfaces.renderkit.html.RichMessageRenderer</name>
- <template>org/richfaces/message.jspx</template>
+ <renderer generate="false" override="true">
+ <name>org.richfaces.renderkit.html.RichMessageBaseRenderer</name>
+ <classname>org.richfaces.renderkit.html.RichMessageHtmlBaseRenderer</classname>
+ <superclass>org.richfaces.renderkit.html.RichMessageBaseRenderer</superclass>
</renderer>
<tag>
<name>message</name>
Modified:
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java 2007-07-23
14:20:09 UTC (rev 1785)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java 2007-07-23
14:21:15 UTC (rev 1786)
@@ -1,6 +1,7 @@
package org.richfaces.component;
import javax.faces.component.UIMessage;
+import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxOutput;
@@ -18,7 +19,17 @@
private String passedLabel = "passed";
private String markerLocation = "left";
+
+ private boolean isError = false;
+ public boolean isError() {
+ return isError;
+ }
+
+ public void setError(boolean isError) {
+ this.isError = isError;
+ }
+
public abstract String getPassedLabel();
public abstract void setPassedLabel(String passedLabel);
@@ -27,4 +38,18 @@
public abstract void setMarkerLocation(String markerLocation);
+ public boolean isAjaxRendered() {
+ return true;
+ }
+
+ public void setAjaxRendered(boolean ajaxRendered) {
+ if(!ajaxRendered){
+ new IllegalArgumentException();
+ }
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ isError = true;
+ super.restoreState(context, state);
+ }
}
\ No newline at end of file
Modified:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-23
14:20:09 UTC (rev 1785)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-23
14:21:15 UTC (rev 1786)
@@ -1,329 +1,49 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
-import javax.faces.application.FacesMessage;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIMessage;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.ComponentVariables;
-import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.richfaces.component.UIRichMessage;
-
-/**
- * @author Anton Belevich
- *
- */
public class RichMessageBaseRenderer extends HeaderResourcesRendererBase{
- private static final Log log = LogFactory.getLog(RichMessageBaseRenderer.class);
+ protected static final Log log = LogFactory.getLog(RichMessageHtmlBaseRenderer.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";
- //TODO nick - anton - local fields are not allowed in renderers
- public boolean isError = false;
- private RendererBase messageTemplate = null;
-
-
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+ protected Iterator getMessageIterator(FacesContext context, String forClientId,
UIComponent component) throws IOException{
Iterator msgIter = null;
- //TODO nick - anton - use || instead of &&
- if(component == null && context == null){
- throw new NullPointerException(NULL_PARAMETER_ERROR_MESSAGE);
- }
-
- if(log.isTraceEnabled()){
- log.trace("begin encoding component: " + component.getId());
- }
-
- if (!component.isRendered()){
- if(log.isTraceEnabled()){
- log.trace("stop encoding component: "
- + component.getId() + " 'rendered' attribute is set to
false");
- }
- return;
- }
-
- UIRichMessage msgComponent = (UIRichMessage)component;
- String clientId = msgComponent.getClientId(context);
- String forClientId = msgComponent.getFor();
-
- //TODO nick - anton - stop encoding messages. we should ALWAYS encode root tag of the
component
- // to handle AJAX re-rendering even if messages are absent
- if(forClientId == null){
- if(log.isInfoEnabled()){
- //TODO nick - anton - error or info?
- log.info(NULL_PARAMETER_ERROR_MESSAGE);
- }
- }
-
- msgIter = getMessageIterator(context, forClientId, msgComponent);
- ResponseWriter writer = context.getResponseWriter();
-
- if(!msgIter.hasNext() && isError){
- //TODO nick - anton - that part of code fully ignores marker location
+ if(forClientId != null && forClientId.length() != 0){
- //TODO nick - anton - check getFacet(...) for null, that wouldn't cause creation
of facets map.
- // refer to JavaDoc for more
- if(msgComponent.getFacets().containsKey("passedMarker")){
-
- UIComponent facet = msgComponent.getFacet("passedMarker");
-
- String markerClass = (String)
msgComponent.getAttributes().get("markerClass");
- String markerStyle = (String)
msgComponent.getAttributes().get("markerStyle");
-
- //TODO nick - anton - huge attributes list
- renderMarkerFacet(msgComponent, facet, context, writer, markerClass, markerStyle);
- }
-
- //TODO nick - anton - store variable here and use it then
- if(msgComponent.getPassedLabel() != null){
-
- String passLabel = (String) msgComponent.getPassedLabel();
- String labelClass = (String)
msgComponent.getAttributes().get("labelClass");
- String labelStyle = (String)
msgComponent.getAttributes().get("labelStyle");
-
- //TODO nick - anton - huge attributes list
- renderLabel(msgComponent, null, context, writer, labelClass,
- labelStyle, false, false, false,passLabel,true);
+ UIComponent result = findForComponent(context, forClientId,component);
+ if (result == null) {
+ msgIter = CollectionUtils.EMPTY_COLLECTION.iterator();
+ } else {
+ msgIter = context.getMessages(result.getClientId(context));
}
-
- }else if(msgIter.hasNext() ){
-
- FacesMessage message = (FacesMessage)msgIter.next();
- encodingUIContent(msgComponent, context, message);
- isError = true;
- }
-
- doEncodeEnd(writer, context, msgComponent);
-
- //TODO nick - anton - too late to add component to re-rendering
- if(isError){
-
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- Set ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
-
- if(null != ajaxRenderedAreas) {
- ajaxRenderedAreas.add(clientId);
- }
- }
- }
-
-
- protected void encodingUIContent(UIRichMessage uiMsg, FacesContext context, FacesMessage
facesMsg) throws IOException{
-
- boolean showSummary = uiMsg.isShowSummary();
-
- boolean showDetail = uiMsg.isShowDetail();
-
- //TODO nick - anton - use getUtils().isBooleanAttribute(component, name)
- // why not make it boolean?
- Object tooltip = uiMsg.getAttributes().get("tooltip");
- boolean isTooltip = false;
- if(tooltip instanceof Boolean){
- isTooltip = ((Boolean)tooltip).booleanValue();
- }
-
- String tableClass = null;
- String tableStyle = null;
-
- String markerClass = null;
- String markerStyle = null;
-
- String labelClass = null;
- String labelStyle = null;
-
- UIComponent markerFacet = null;
-
-
- if(facesMsg.getSeverity() == FacesMessage.SEVERITY_ERROR){
-
- tableClass = (String)uiMsg.getAttributes().get("errorClass");
- tableStyle = (String)uiMsg.getAttributes().get("errorStyle");
-
- markerClass = (String)uiMsg.getAttributes().get("errorMarkerClass");
- markerStyle = (String)uiMsg.getAttributes().get("errorMarkerStyle");
-
- labelClass = (String)uiMsg.getAttributes().get("errorLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("errorLabelStyle");
-
- markerFacet = uiMsg.getFacet("errorMarker");
-
- }else if(facesMsg.getSeverity() == FacesMessage.SEVERITY_FATAL){
-
- tableClass = (String)uiMsg.getAttributes().get("fatalClass");
- tableStyle = (String)uiMsg.getAttributes().get("fatalStyle");
-
- markerClass = (String)uiMsg.getAttributes().get("fatalMarkerClass");
- markerStyle = (String)uiMsg.getAttributes().get("fatalMarkerStyle");
-
- labelClass = (String)uiMsg.getAttributes().get("fatalLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("fatalLabelStyle");
-
- markerFacet = uiMsg.getFacet("fatalMarker");
-
- }else if(facesMsg.getSeverity() == FacesMessage.SEVERITY_WARN){
-
- tableClass = (String)uiMsg.getAttributes().get("warnClass");
- tableStyle = (String)uiMsg.getAttributes().get("warnStyle");
-
- markerClass = (String)uiMsg.getAttributes().get("warnMarkerClass");
- markerStyle = (String)uiMsg.getAttributes().get("warnMarkerStyle");
-
- labelClass = (String)uiMsg.getAttributes().get("warnLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("warnLabelStyle");
-
- markerFacet = uiMsg.getFacet("warnMarker");
-
- }else if(facesMsg.getSeverity() == FacesMessage.SEVERITY_INFO){
-
- tableClass = (String)uiMsg.getAttributes().get("infoClass");
- tableStyle = (String)uiMsg.getAttributes().get("infoStyle");
-
- markerClass = (String)uiMsg.getAttributes().get("infoMarkerClass");
- markerStyle = (String)uiMsg.getAttributes().get("infoMarkerStyle");
-
- labelClass = (String)uiMsg.getAttributes().get("infoLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("infoLabelStyle");
-
- markerFacet = uiMsg.getFacet("infoMarker");
- }
-
- String markerLocation = uiMsg.getMarkerLocation();
- markerLocation = markerLocation.toLowerCase();
-
- ResponseWriter writer = context.getResponseWriter();
-
- messageTemplate = getMessageTemplate();
-
- ComponentVariables variables = ComponentsVariableResolver.getVariables(messageTemplate,
uiMsg);
- variables.setVariable("tableClass", tableClass);
- variables.setVariable("tableStyle", tableStyle);
-
- if(markerLocation.equals(uiMsg.MARKER_LOCATION_LEFT)){
- renderMarkerFacet(uiMsg,markerFacet,context, writer, markerClass, markerStyle);
- renderLabel(uiMsg, facesMsg, context, writer, labelClass,
- labelStyle, isTooltip, showDetail,showSummary,null,false);
- }else if(markerLocation.equals(uiMsg.MARKER_LOCATION_RIGHT)){
- renderLabel(uiMsg, facesMsg, context, writer, labelClass,
- labelStyle, isTooltip, showDetail, showSummary,null,false);
- renderMarkerFacet(uiMsg,markerFacet,context, writer, markerClass, markerStyle);
- }
- }
-
- protected void renderMarkerFacet(UIRichMessage uiMsg, UIComponent marker, FacesContext
context, ResponseWriter writer, String markerClass, String markerStyle) throws
IOException{
-
- //TODO nick - anton - check if marker is rendered
- if(marker == null){
- return;
- }
-
- //TODO nick - anton - default message element is rendered as span. Consider revising
FuncSpec-RF-M-NFR-010-1.0 layout
- writer.startElement(HTML.td_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.td_ELEM);
-
- }
-
- protected void renderLabel(UIRichMessage uiMsg, FacesMessage msg, FacesContext context,
- ResponseWriter writer, String labelClass, String labelStyle,
- boolean isTooltip, boolean showDetail, boolean showSummary,
- String passLabel, boolean isPassLabel) throws IOException{
-
- String summary = null;
-
- String detail = null;
-
- if(msg != null){
- summary = (null != (summary = msg.getSummary())) ? summary : "";
- detail = (null != (detail = msg.getDetail())) ? detail : "";
- }
-
- String classes = labelClass == null ? "rich-message-label" :
"rich-message-label " + labelClass;
-
- writer.startElement(HTML.td_ELEM, uiMsg);
- writer.startElement(HTML.SPAN_ELEM, uiMsg);
-
- getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE,classes);
- getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, labelStyle);
-
- if(isTooltip){
- 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);
- }
-
- if(isPassLabel){
- writer.writeText(passLabel, null);
- writer.writeText("\t", null);
- }
-
- writer.endElement(HTML.SPAN_ELEM);
- writer.endElement(HTML.td_ELEM);
-
- }
-
- protected Iterator getMessageIterator(FacesContext context, String forClientId,
UIComponent component){
-
- Iterator msgIter = null;
-
- if(forClientId != null){
-
- if(forClientId.length() == 0){
- msgIter = context.getMessages(null);
- }else{
- UIComponent result = findForComponent(context, forClientId,component);
- if (result == null) {
- //TODO nick - anton consider using CollectionUtils.EMPTY_COLLECTION.iterator()
- msgIter = Collections.EMPTY_LIST.iterator();
- } else {
- msgIter = context.getMessages(result.getClientId(context));
- }
- }
}else{
- //TODO nick - anton - no need for global messages
+ msgIter = context.getMessages(null);
msgIter = context.getMessages();
}
return msgIter;
}
- //TODO nick - anton - candidate for utility method
- protected UIComponent findForComponent(FacesContext context, String forClientId,
UIComponent component){
+ protected UIComponent findForComponent(FacesContext context, String forClientId,
UIComponent component) throws IOException{
if(null == forClientId || forClientId.length() == 0){
return null;
@@ -332,25 +52,19 @@
UIComponent result = null;
UIComponent parent = component;
- try{
- while(parent != null){
- result = parent.findComponent(forClientId);
-
- if(result != null){
- break;
- }
- parent = parent.getParent();
- }
-
- if(result == null){
- result = findComponentBelow(context.getViewRoot(), forClientId);
+ while(parent != null){
+ result = parent.findComponent(forClientId);
+
+ if(result != null){
+ break;
}
-
- } catch(Throwable t){
- //TODO nick - anton - do not catch Throwables!!! you can catch OutOfMemoryError and
swallow it here
- throw new RuntimeException(COMPONENT_NOT_FOUND_IN_VIEW_WARN_MESSAGE + ":"+
forClientId);
+ 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);
@@ -363,7 +77,11 @@
protected UIComponent findComponentBelow(UIComponent startComponent, String
forClientId){
UIComponent retComp = null;
- //TODO nick - anton - better check if getChildCount() == 0 first
+
+ if(startComponent.getChildCount() == 0){
+ return null;
+ }
+
List children = startComponent.getChildren();
for(int i = 0, size = children.size(); i < size; i++){
@@ -386,29 +104,9 @@
return retComp;
};
- private RendererBase getMessageTemplate(){
- //TODO nick - anton - really so no need for external template renderer
- //TODO nick - anton - such code blocks should be somehow synchronized
- if (messageTemplate == null) {
- try {
-
- messageTemplate =
(RendererBase)Class.forName("org.richfaces.renderkit.html.RichMessageRenderer").newInstance();
+ protected Class getComponentClass() {
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- return messageTemplate;
+ return UIMessage.class;
}
-
- protected Class getComponentClass(){
- //TODO nick - anton - return UIMessage.class here
- return getClass();
- }
+
}
-
\ No newline at end of file
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java
(rev 0)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java 2007-07-23
14:21:15 UTC (rev 1786)
@@ -0,0 +1,333 @@
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIComponent;
+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;
+
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class RichMessageHtmlBaseRenderer 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 {
+ java.util.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;
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+
+ Iterator msgIter = null;
+
+ if(component == null || context == null){
+ throw new NullPointerException(NULL_PARAMETER_ERROR_MESSAGE);
+ }
+
+ if(log.isTraceEnabled()){
+ log.trace("begin encoding component: " + component.getId());
+ }
+
+ if (!component.isRendered()){
+
+ if(log.isTraceEnabled()){
+ log.trace("stop encoding component: "
+ + component.getId() + " 'rendered' attribute is set to
false");
+ }
+
+ return;
+ }
+
+ 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);
+ ResponseWriter writer = context.getResponseWriter();
+
+ if(!msgIter.hasNext() && msgComponent.isError()){
+
+ encodingUIContent(msgComponent, context, null);
+
+ }else if(msgIter.hasNext() ){
+
+ FacesMessage message = (FacesMessage)msgIter.next();
+ encodingUIContent(msgComponent, context, message);
+
+ }
+
+ doEncodeEnd(writer, context, msgComponent);
+
+ }
+ }
+
+ protected void encodingUIContent(UIRichMessage uiMsg, FacesContext context, FacesMessage
facesMsg) throws IOException{
+
+ String markerLocation = uiMsg.getMarkerLocation();
+ markerLocation = markerLocation.toLowerCase();
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.SPAN_ELEM, uiMsg);
+ getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE, uiMsg.getClientId(context));
+
+ if(markerLocation.equals(uiMsg.MARKER_LOCATION_LEFT)){
+
+ renderMarkerFacet(uiMsg,context, writer,facesMsg);
+ renderLabel(uiMsg, context, writer, facesMsg);
+
+ }else if(markerLocation.equals(uiMsg.MARKER_LOCATION_RIGHT)){
+
+ renderLabel(uiMsg, context, writer, facesMsg);
+ renderMarkerFacet(uiMsg,context, writer,facesMsg);
+
+ }
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ protected void renderMarkerFacet(UIRichMessage 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;
+ }
+
+ 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);
+
+ }
+
+ protected void renderLabel(UIRichMessage uiMsg, FacesContext context, ResponseWriter
writer,FacesMessage facesMsg) throws IOException{
+
+ String summary = null;
+
+ String detail = null;
+
+ String labelClass = null;
+
+ String labelStyle = null;
+
+ String outerClass = null;
+
+ String outerStyle = null;
+
+ String passLabel = null;
+
+ Severity severity = null;
+
+ boolean isTooltip = getUtils().isBooleanAttribute(uiMsg, "tooltip");
+
+ boolean showSummary = uiMsg.isShowSummary();
+
+ boolean showDetail = uiMsg.isShowDetail();
+
+ boolean isPassLabel = false;
+
+ if(facesMsg != null){
+
+ severity = facesMsg.getSeverity();
+
+
+ if(severity == FacesMessage.SEVERITY_ERROR){
+
+ outerClass = (String)uiMsg.getAttributes().get("errorClass");
+ outerStyle = (String)uiMsg.getAttributes().get("errorStyle");
+
+ labelClass = (String)uiMsg.getAttributes().get("errorLabelClass");
+ labelStyle = (String)uiMsg.getAttributes().get("errorLabelStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_FATAL){
+
+ outerClass = (String)uiMsg.getAttributes().get("fatalClass");
+ outerStyle = (String)uiMsg.getAttributes().get("fatalStyle");
+
+ labelClass = (String)uiMsg.getAttributes().get("fatalLabelClass");
+ labelStyle = (String)uiMsg.getAttributes().get("fatalLabelStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_WARN){
+
+ outerClass = (String)uiMsg.getAttributes().get("warnClass");
+ outerStyle = (String)uiMsg.getAttributes().get("warnStyle");
+
+ labelClass = (String)uiMsg.getAttributes().get("warnLabelClass");
+ labelStyle = (String)uiMsg.getAttributes().get("warnLabelStyle");
+
+ }else if(severity == FacesMessage.SEVERITY_INFO){
+
+ outerClass = (String)uiMsg.getAttributes().get("infoClass");
+ outerStyle = (String)uiMsg.getAttributes().get("infoStyle");
+
+ labelClass = (String)uiMsg.getAttributes().get("infoLabelClass");
+ labelStyle = (String)uiMsg.getAttributes().get("infoLabelStyle");
+
+ }
+
+ }else if(uiMsg.getPassedLabel() != null){
+
+ passLabel = (String) uiMsg.getPassedLabel();
+ labelClass = (String) uiMsg.getAttributes().get("labelClass");
+ labelStyle = (String) uiMsg.getAttributes().get("labelStyle");
+ isPassLabel = true;
+
+ }
+
+ if(facesMsg != null){
+ summary = (null != (summary = facesMsg.getSummary())) ? summary : "";
+ detail = (null != (detail = facesMsg.getDetail())) ? detail : "";
+ }
+
+
+ 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 ? outerClass + " ," :
"");
+
+ parentStyle = parentStyle != null ? (richMessageStyle + parentStyle) : parentStyle;
+ parentClass = parentClass != null ? (richMessageClass + parentClass) : parentClass;
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, parentClass);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, parentStyle);
+
+ 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){
+ 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(isPassLabel){
+ writer.writeText(passLabel, null);
+ writer.writeText("\t", null);
+ }
+ }
+
+ writer.endElement(HTML.SPAN_ELEM);
+
+ }
+}
+
\ No newline at end of file
Modified:
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msg.css
===================================================================
---
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msg.css 2007-07-23
14:20:09 UTC (rev 1785)
+++
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msg.css 2007-07-23
14:21:15 UTC (rev 1786)
@@ -6,3 +6,9 @@
.rich-message-label{
}
+
+.rich-message-marker *{
+ vertical-align: middle;
+}
+
+