Author: abelevich
Date: 2007-07-24 13:56:41 -0400 (Tue, 24 Jul 2007)
New Revision: 1829
Added:
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msgs.css
Modified:
trunk/sandbox/ui/message/src/main/config/component/message.xml
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java
Log:
add new component richfaces messages, move renderLabel and renderMarker methods to
RichMessageBaseRenderer.java
Modified: trunk/sandbox/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-24 17:14:02 UTC
(rev 1828)
+++ trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-24 17:56:41 UTC
(rev 1829)
@@ -137,11 +137,16 @@
</property>
<property>
- <name>MarkerClass</name>
+ <name>markerClass</name>
<classname>java.lang.String</classname>
- </property>
+ </property>
<property>
+ <name>markerStyle</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
<name>errorLabelClass</name>
<classname>java.lang.String</classname>
</property>
@@ -162,7 +167,7 @@
</property>
<property>
- <name>LabelClass</name>
+ <name>labelClass</name>
<classname>java.lang.String</classname>
</property>
@@ -173,5 +178,206 @@
&ui_component_attributes;
</component>
+
+ <component>
+ <name>org.richfaces.component.RichMessages</name>
+ <family>org.richfaces.component.RichMessages</family>
+ <classname>
+ org.richfaces.component.html.HtmlRichMessages
+ </classname>
+ <superclass>org.richfaces.component.UIRichMessages</superclass>
+
+ <test>
+ <classname>org.richfaces.component.html.HtmlRichMessagesTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ </test>
+ <description>
+ <![CDATA[ richfaces Messages Component ]]>
+ </description>
+
+ <renderer generate="false" override="true">
+ <name>org.richfaces.renderkit.html.RichMessagesBaseRenderer</name>
+ <classname>org.richfaces.renderkit.html.RichMessagesHtmlBaseRenderer</classname>
+ <superclass>org.richfaces.renderkit.html.RichMessageBaseRenderer</superclass>
+ </renderer>
+
+ <tag>
+ <name>messages</name>
+ <classname>org.richfaces.taglib.RichMessagesTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+
+ <test>
+ <classname>org.richfaces.taglib.RichMessagesTagTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ </test>
+ </tag>
+
+ <property attachedstate="true">
+ <name>passedLabel</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>"passed"</defaultvalue>
+ <description>
+ Attribute should define the label to be displayed when no message appears
+ </description>
+ </property>
+
+ <property>
+ <name>var</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>layout</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>"List"</defaultvalue>
+ </property>
+
+ <property>
+ <name>headerLocation</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>globalOnly</name>
+ <classname>boolean</classname>
+ <defaultvalue>false</defaultvalue>
+ </property>
+
+ <property>
+ <name>showDetail</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
+
+ <property>
+ <name>showSummary</name>
+ <classname>boolean</classname>
+ <defaultvalue>false</defaultvalue>
+ </property>
+
+ <property>
+ <name>title</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>tooltip</name>
+ <classname>boolean</classname>
+ </property>
+
+ <property>
+ <name>headerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>headerStyle</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>errorClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>fatalClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>infoClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>styleClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>style</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>warnClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>errorMarkerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>warnClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>errorMarkerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>fatalMarkerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>infoMarkerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>warnMarkerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>markerClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>markerStyle</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>errorLabelClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>fatalLabelClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>infoLabelClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>warnLabelClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>labelClass</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property attachedstate="true" hidden="true">
+ <name>binding</name>
+ <classname>javax.faces.component.UIComponent</classname>
+ </property>
+
+ &ui_component_attributes;
+ </component>
+
</components>
\ No newline at end of file
Added: trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
--- trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
(rev 0)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2007-07-24
17:56:41 UTC (rev 1829)
@@ -0,0 +1,42 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import javax.faces.component.UIMessages;
+
+import org.ajax4jsf.component.AjaxOutput;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public abstract class UIRichMessages extends UIMessages implements AjaxOutput {
+
+ private boolean wroteTable = false;
+
+
+ public boolean isWroteTable() {
+ return wroteTable;
+ }
+
+ public void setWroteTable(boolean wroteTable) {
+ this.wroteTable = wroteTable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.component.AjaxOutput#isAjaxRendered()
+ */
+ public boolean isAjaxRendered() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.component.AjaxOutput#setAjaxRendered(boolean)
+ */
+ public void setAjaxRendered(boolean ajaxRendered) {
+ if(!ajaxRendered){
+ new IllegalArgumentException();
+ }
+ }
+}
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-24
17:14:02 UTC (rev 1828)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-24
17:56:41 UTC (rev 1829)
@@ -4,17 +4,19 @@
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.component.UIMessage;
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;
-public class RichMessageBaseRenderer extends HeaderResourcesRendererBase{
+public abstract class RichMessageBaseRenderer extends HeaderResourcesRendererBase{
protected static final Log log = LogFactory.getLog(RichMessageHtmlBaseRenderer.class);
@@ -43,6 +45,114 @@
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 UIComponent findForComponent(FacesContext context, String forClientId,
UIComponent component) throws IOException{
if(null == forClientId || forClientId.length() == 0){
@@ -104,9 +214,9 @@
return retComp;
};
- protected Class getComponentClass() {
+ public abstract void renderMarkerHtml(UIComponent component, UIComponent markerFacet,
FacesContext context, ResponseWriter writer,
+ String markerClass, String markerStyle) throws IOException;
- return UIMessage.class;
- }
-
+ public abstract void renderLabelHtml(UIComponent component, FacesContext context,
ResponseWriter writer,
+ FacesMessage facesMsg, String labelClass, String labelStyle, String passLabel)
throws IOException;
}
Modified:
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 2007-07-24
17:14:02 UTC (rev 1828)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java 2007-07-24
17:56:41 UTC (rev 1829)
@@ -2,10 +2,12 @@
import java.io.IOException;
import java.util.Iterator;
+import java.util.Set;
import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIMessage;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -25,30 +27,33 @@
private InternetResource[] stylesAll = null;
- protected InternetResource[] getStyles() {
- synchronized (this) {
- if (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(ignoreSuper){
+
if (ignoreThis) {
stylesAll = new InternetResource[0];
} else {
stylesAll = styles;
}
- } else {
- if (ignoreThis) {
+
+ }else{
+ if(ignoreThis){
stylesAll = rsrcs;
- } else {
- java.util.Set rsrcsSet = new java.util.LinkedHashSet();
+ }else{
+ Set rsrcsSet = new java.util.LinkedHashSet();
- for (int i = 0; i < rsrcs.length; i++ ) {
+ for(int i = 0; i < rsrcs.length; i++ ){
rsrcsSet.add(rsrcs[i]);
}
- for (int i = 0; i < styles.length; i++ ) {
+ for(int i = 0; i < styles.length; i++ ){
rsrcsSet.add(styles[i]);
}
@@ -61,28 +66,11 @@
return stylesAll;
}
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+
+ protected void doEncodeEnd(ResponseWriter writer, 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();
@@ -95,8 +83,7 @@
}else{
msgIter = getMessageIterator(context, forClientId, msgComponent);
- ResponseWriter writer = context.getResponseWriter();
-
+
if(!msgIter.hasNext() && msgComponent.isPassed()){
encodingUIContent(msgComponent, context, null);
@@ -107,12 +94,9 @@
encodingUIContent(msgComponent, context, message);
}
-
- doEncodeEnd(writer, context, msgComponent);
-
}
}
-
+
protected void encodingUIContent(UIRichMessage uiMsg, FacesContext context, FacesMessage
facesMsg) throws IOException{
ResponseWriter writer = context.getResponseWriter();
@@ -129,110 +113,55 @@
protected void renderOuterStyle(UIRichMessage uiMsg, FacesContext context,
ResponseWriter writer,FacesMessage facesMsg) throws IOException{
- String outerClass = null;
+ String outerClass = null;
- String outerStyle = null;
+ String outerStyle = null;
- Severity severity = null;
+ Severity severity = null;
- if(facesMsg != null){
+ if(facesMsg != null){
- severity = facesMsg.getSeverity();
-
- if(severity == FacesMessage.SEVERITY_ERROR){
+ severity = facesMsg.getSeverity();
+ if(severity == FacesMessage.SEVERITY_ERROR){
- outerClass = (String)uiMsg.getAttributes().get("errorClass");
- outerStyle = (String)uiMsg.getAttributes().get("errorStyle");
+ outerClass = (String)uiMsg.getAttributes().get("errorClass");
+ outerStyle = (String)uiMsg.getAttributes().get("errorStyle");
- }else if(severity == FacesMessage.SEVERITY_FATAL){
+ }else if(severity == FacesMessage.SEVERITY_FATAL){
- outerClass = (String)uiMsg.getAttributes().get("fatalClass");
- outerStyle = (String)uiMsg.getAttributes().get("fatalStyle");
+ outerClass = (String)uiMsg.getAttributes().get("fatalClass");
+ outerStyle = (String)uiMsg.getAttributes().get("fatalStyle");
- }else if(severity == FacesMessage.SEVERITY_WARN){
+ }else if(severity == FacesMessage.SEVERITY_WARN){
- outerClass = (String)uiMsg.getAttributes().get("warnClass");
- outerStyle = (String)uiMsg.getAttributes().get("warnStyle");
+ outerClass = (String)uiMsg.getAttributes().get("warnClass");
+ outerStyle = (String)uiMsg.getAttributes().get("warnStyle");
- }else if(severity == FacesMessage.SEVERITY_INFO){
+ }else if(severity == FacesMessage.SEVERITY_INFO){
- outerClass = (String)uiMsg.getAttributes().get("infoClass");
- outerStyle = (String)uiMsg.getAttributes().get("infoStyle");
- }
- }
+ outerClass = (String)uiMsg.getAttributes().get("infoClass");
+ outerStyle = (String)uiMsg.getAttributes().get("infoStyle");
+ }
+ }
- String parentStyle = (String)uiMsg.getAttributes().get("style");
- String parentClass = (String)uiMsg.getAttributes().get("styleClass");
+ 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 + " ," :
"");
+ String richMessageClass = "rich-message" + (null != outerClass ? (outerClass
+ " ") : "");
+ String richMessageStyle = (null != outerStyle ? outerClass + " ," :
"");
- parentStyle = parentStyle != null ? (richMessageStyle + parentStyle) :
richMessageStyle;
- parentClass = parentClass != null ? (richMessageClass + parentClass) :
richMessageClass;
+ 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);
-
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, parentClass);
+ getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, parentStyle);
+
}
- protected void renderMarkerFacet(UIRichMessage uiMsg, FacesContext context,
ResponseWriter writer,FacesMessage facesMsg) throws IOException{
-
- UIComponent marker = null;
+ public void renderMarkerHtml(UIComponent uiMsg,UIComponent marker, FacesContext context,
+ ResponseWriter writer,String markerClass, String markerStyle) throws
IOException{
- 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;
@@ -243,111 +172,74 @@
renderChild(context, marker);
writer.endElement(HTML.SPAN_ELEM);
-
+
}
- protected void renderLabel(UIRichMessage uiMsg, FacesContext context, ResponseWriter
writer,FacesMessage facesMsg) throws IOException{
+ public void renderLabelHtml(UIComponent component, FacesContext context, ResponseWriter
writer,
+ FacesMessage facesMsg, String labelClass, String labelStyle, String passLabel)
throws IOException{
+
+ String summary = null;
- String summary = null;
-
- String detail = null;
-
- String labelClass = null;
-
- String labelStyle = null;
-
- String passLabel = null;
-
- Severity severity = null;
-
- String title = null;
-
- boolean isTooltip = getUtils().isBooleanAttribute(uiMsg, "tooltip");
-
- boolean showSummary = uiMsg.isShowSummary();
+ String detail = null;
- boolean showDetail = uiMsg.isShowDetail();
-
- boolean isPassLabel = false;
-
-
- if(facesMsg != null){
-
- severity = facesMsg.getSeverity();
+ String title = null;
+
+ UIRichMessage 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 : "";
+ }
- if(severity == FacesMessage.SEVERITY_ERROR){
-
- labelClass = (String)uiMsg.getAttributes().get("errorLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("errorLabelStyle");
-
- }else if(severity == FacesMessage.SEVERITY_FATAL){
-
- labelClass = (String)uiMsg.getAttributes().get("fatalLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("fatalLabelStyle");
-
- }else if(severity == FacesMessage.SEVERITY_WARN){
-
- labelClass = (String)uiMsg.getAttributes().get("warnLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("warnLabelStyle");
-
- }else if(severity == FacesMessage.SEVERITY_INFO){
-
- labelClass = (String)uiMsg.getAttributes().get("infoLabelClass");
- labelStyle = (String)uiMsg.getAttributes().get("infoLabelStyle");
-
+ 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);
+ }
}
- }else if(uiMsg.getPassedLabel() != null){
+ 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);
- 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 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(isPassLabel){
- 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/RichMessagesHtmlBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java
(rev 0)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java 2007-07-24
17:56:41 UTC (rev 1829)
@@ -0,0 +1,247 @@
+/**
+ *
+ */
+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.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.UIRichMessage;
+import org.richfaces.component.UIRichMessages;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class RichMessagesHtmlBaseRenderer extends RichMessageBaseRenderer {
+
+ 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 {
+
+ Iterator messagesIter = null;
+
+ String forIds = null;
+
+ String layout = null;
+
+
+ UIRichMessages uiMessages = (UIRichMessages)component;
+
+ if(uiMessages.isGlobalOnly()){
+ forIds = "";
+ }
+
+ messagesIter = getMessageIterator(context, forIds, component);
+
+ if((layout != null) && (layout.equals("table"))){
+
+ writer.startElement("table", component);
+ getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
uiMessages.getClientId(context));
+ renderHeaderFacet(writer, context, uiMessages);
+ writer.startElement("tbody", uiMessages);
+ uiMessages.setWroteTable(true);
+
+ }else if((layout != null) && (layout.equals("iterator"))){
+ // TODO will implement this behaviour soon!!!
+ }else{
+ writer.startElement("ul", component);
+ }
+
+ while(messagesIter.hasNext()){
+
+ FacesMessage facesMsg = (FacesMessage)(messagesIter.next());
+
+ writer.startElement(HTML.TR_ELEMENT, component);
+
+ renderMarkerFacet(uiMessages, context, writer, facesMsg);
+ renderLabel(uiMessages, context, writer, facesMsg);
+
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ if(uiMessages.isWroteTable()){
+ writer.endElement("tbody");
+ writer.endElement("table");
+ }else{
+ writer.endElement("ul");
+ }
+
+ }
+
+ 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 = (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-messages-label" :
"rich-messages-label " + labelClass;
+
+
+ writer.startElement(HTML.td_ELEM, component);
+
+ 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.td_ELEM);
+
+ }
+
+ public void renderMarkerHtml(UIComponent component, UIComponent markerFacet,
FacesContext context,
+ ResponseWriter writer, String markerClass, String markerStyle)throws IOException
{
+
+ UIRichMessages uiMessages = (UIRichMessages)component;
+ if(uiMessages.isWroteTable()){
+
+ writer.startElement(HTML.td_ELEM, component);
+
+ 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);
+
+ writer.endElement(HTML.td_ELEM);
+
+ }else{
+
+ }
+ }
+
+ public void renderHeaderFacet(ResponseWriter writer, FacesContext context,
UIRichMessages uiMessages) throws IOException{
+
+ UIComponent facet = null;
+
+ String headerClass = null;
+
+ String headerStyle = null;
+
+
+ headerClass = (String)uiMessages.getAttributes().get("headerClass");
+
+ headerStyle = (String)uiMessages.getAttributes().get("headerStyle");
+
+ if(uiMessages.getFacet("header") != null){
+
+ facet = uiMessages.getFacet("header");
+
+ if(!facet.isRendered()){
+ return;
+ }
+
+ writer.startElement(HTML.THEAD_ELEMENT, uiMessages);
+ writer.startElement(HTML.TR_ELEMENT, uiMessages);
+ writer.startElement(HTML.td_ELEM, uiMessages);
+
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, headerClass);
+ getUtils().writeAttribute(writer,HTML.style_ATTRIBUTE, headerStyle);
+
+ renderChild(context, facet);
+
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.endElement(HTML.THEAD_ELEMENT);
+ }
+ }
+
+ protected Class getComponentClass() {
+ return UIMessages.class;
+ }
+
+}
Added:
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msgs.css
===================================================================
--- trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msgs.css
(rev 0)
+++
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msgs.css 2007-07-24
17:56:41 UTC (rev 1829)
@@ -0,0 +1,11 @@
+.rich-messages-marker{
+}
+
+.rich-messages{
+}
+
+.rich-messages-label{
+}
+
+.rich-messages-header{
+}