Author: abelevich
Date: 2007-07-25 08:43:47 -0400 (Wed, 25 Jul 2007)
New Revision: 1839
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/component/UIRichMessages.java
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
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
Log:
pre-final message and messages (without headerLocation attribute) components impl
Modified: trunk/sandbox/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-25 11:33:03 UTC
(rev 1838)
+++ trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-25 12:43:47 UTC
(rev 1839)
@@ -75,6 +75,7 @@
<property>
<name>tooltip</name>
<classname>boolean</classname>
+ <defaultvalue>false</defaultvalue>
</property>
<property>
@@ -232,12 +233,13 @@
<property>
<name>layout</name>
<classname>java.lang.String</classname>
- <defaultvalue>"List"</defaultvalue>
+ <defaultvalue>"list"</defaultvalue>
</property>
<property>
<name>headerLocation</name>
<classname>java.lang.String</classname>
+ <defaultvalue>"top"</defaultvalue>
</property>
<property>
@@ -266,6 +268,7 @@
<property>
<name>tooltip</name>
<classname>boolean</classname>
+ <defaultvalue>false</defaultvalue>
</property>
<property>
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-25
11:33:03 UTC (rev 1838)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessage.java 2007-07-25
12:43:47 UTC (rev 1839)
@@ -12,8 +12,6 @@
*/
public abstract class UIRichMessage extends UIMessage implements AjaxOutput{
- private String passedLabel = "passed";
-
private boolean isPassed = false;
public boolean isPassed() {
Modified:
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
---
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2007-07-25
11:33:03 UTC (rev 1838)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2007-07-25
12:43:47 UTC (rev 1839)
@@ -15,7 +15,9 @@
private boolean wroteTable = false;
+ private boolean isIteratorLayout = false;
+
public boolean isWroteTable() {
return wroteTable;
}
@@ -24,6 +26,14 @@
this.wroteTable = wroteTable;
}
+ public boolean isIteratorLayout() {
+ return isIteratorLayout;
+ }
+
+ public void setIteratorLayout(boolean isIteratorLayout) {
+ this.isIteratorLayout = isIteratorLayout;
+ }
+
/* (non-Javadoc)
* @see org.ajax4jsf.component.AjaxOutput#isAjaxRendered()
*/
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-25
11:33:03 UTC (rev 1838)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-25
12:43:47 UTC (rev 1839)
@@ -153,6 +153,44 @@
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){
@@ -219,4 +257,6 @@
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;
}
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-25
11:33:03 UTC (rev 1838)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java 2007-07-25
12:43:47 UTC (rev 1839)
@@ -5,7 +5,6 @@
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;
@@ -104,64 +103,47 @@
writer.startElement(HTML.SPAN_ELEM, uiMsg);
getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE, uiMsg.getClientId(context));
- renderOuterStyle(uiMsg, context, writer, facesMsg);
+ outerStyles(uiMsg, context, writer, facesMsg);
renderMarkerFacet(uiMsg,context, writer,facesMsg);
renderLabel(uiMsg, context, writer, facesMsg);
writer.endElement(HTML.SPAN_ELEM);
}
- protected void renderOuterStyle(UIRichMessage uiMsg, FacesContext context,
ResponseWriter writer,FacesMessage facesMsg) throws IOException{
+ public void renderOuterStyles(UIComponent component, FacesContext context,
ResponseWriter writer,String outerStyle, String outerClass) throws IOException{
- String outerClass = null;
-
- String outerStyle = null;
-
- Severity severity = null;
-
-
- if(facesMsg != null){
-
- severity = facesMsg.getSeverity();
- if(severity == FacesMessage.SEVERITY_ERROR){
-
- outerClass = (String)uiMsg.getAttributes().get("errorClass");
- outerStyle = (String)uiMsg.getAttributes().get("errorStyle");
-
- }else if(severity == FacesMessage.SEVERITY_FATAL){
-
- outerClass = (String)uiMsg.getAttributes().get("fatalClass");
- outerStyle = (String)uiMsg.getAttributes().get("fatalStyle");
-
- }else if(severity == FacesMessage.SEVERITY_WARN){
-
- outerClass = (String)uiMsg.getAttributes().get("warnClass");
- outerStyle = (String)uiMsg.getAttributes().get("warnStyle");
-
- }else if(severity == FacesMessage.SEVERITY_INFO){
-
- outerClass = (String)uiMsg.getAttributes().get("infoClass");
- outerStyle = (String)uiMsg.getAttributes().get("infoStyle");
- }
+ 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 ? 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 uiMsg,UIComponent marker, FacesContext context,
+ 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;
@@ -184,8 +166,14 @@
String title = null;
- UIRichMessage uiMsg = (UIRichMessage)component;
+ UIRichMessage uiMsg = null;
+ if(!(component instanceof UIRichMessage)){
+ return;
+ }
+
+ uiMsg = (UIRichMessage)component;
+
boolean isTooltip = getUtils().isBooleanAttribute(uiMsg, "tooltip");
boolean showSummary = uiMsg.isShowSummary();
Modified:
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 2007-07-25
11:33:03 UTC (rev 1838)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java 2007-07-25
12:43:47 UTC (rev 1839)
@@ -5,8 +5,10 @@
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;
@@ -15,7 +17,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.component.UIRichMessage;
import org.richfaces.component.UIRichMessages;
/**
@@ -30,7 +31,9 @@
protected InternetResource[] getStyles(){
+
synchronized (this){
+
if(stylesAll == null){
InternetResource[] rsrcs = super.getStyles();
@@ -46,11 +49,12 @@
}
}else{
+
if(ignoreThis){
stylesAll = rsrcs;
}else{
+
Set rsrcsSet = new java.util.LinkedHashSet();
-
for(int i = 0; i < rsrcs.length; i++ ){
rsrcsSet.add(rsrcs[i]);
}
@@ -61,7 +65,9 @@
stylesAll = (InternetResource[]) rsrcsSet.toArray(new
InternetResource[rsrcsSet.size()]);
}
+
}
+
}
}
@@ -76,7 +82,9 @@
String layout = null;
+ String var = null;
+
UIRichMessages uiMessages = (UIRichMessages)component;
if(uiMessages.isGlobalOnly()){
@@ -84,40 +92,76 @@
}
messagesIter = getMessageIterator(context, forIds, component);
-
+
+ layout = (String)uiMessages.getAttributes().get("layout");
if((layout != null) && (layout.equals("table"))){
writer.startElement("table", component);
getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
uiMessages.getClientId(context));
+ getUtils().writeAttribute(writer, HTML.cellpadding_ATTRIBUTE, "0");
+ getUtils().writeAttribute(writer, HTML.cellspacing_ATTRIBUTE, "0");
+
renderHeaderFacet(writer, context, uiMessages);
+ renderComponentOuterStyles(uiMessages, context, writer);
writer.startElement("tbody", uiMessages);
uiMessages.setWroteTable(true);
}else if((layout != null) && (layout.equals("iterator"))){
- // TODO will implement this behaviour soon!!!
- }else{
+
+ var = (String)uiMessages.getAttributes().get("var");
+ if(var == null){
+ FacesException e = new FacesException(new IllegalArgumentException("var
attribute is not defined"));
+ throw e;
+ }
+
+ uiMessages.setIteratorLayout(true);
+
+ }else if((layout != null) && (layout.equals("list"))){
+
writer.startElement("ul", component);
+ getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
uiMessages.getClientId(context));
+ renderComponentOuterStyles(uiMessages, context, writer);
+
}
while(messagesIter.hasNext()){
FacesMessage facesMsg = (FacesMessage)(messagesIter.next());
- writer.startElement(HTML.TR_ELEMENT, component);
+ if(!uiMessages.isIteratorLayout()){
+
+ if(uiMessages.isWroteTable()){
+ writer.startElement(HTML.TR_ELEMENT, component);
+ }else{
+ writer.startElement("li", component);
+ }
+
+ outerStyles(component, context, writer, facesMsg);
+ renderMarkerFacet(uiMessages, context, writer, facesMsg);
+ renderLabel(uiMessages, context, writer, facesMsg);
+
+ if(uiMessages.isWroteTable()){
+ writer.endElement(HTML.TR_ELEMENT);
+ }else{
+ writer.endElement("li");
+ }
+
+ if(uiMessages.isWroteTable()){
+ writer.endElement("tbody");
+ writer.endElement("table");
+ }else{
+ writer.endElement("ul");
+ }
+
+ }else{
+
+ Map requestMap = context.getExternalContext().getRequestMap();
+ requestMap.put(var, facesMsg);
- 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,
@@ -129,36 +173,48 @@
String title = null;
- UIRichMessage uiMsg = (UIRichMessage)component;
+ UIRichMessages uiMessages = null;
- boolean isTooltip = getUtils().isBooleanAttribute(uiMsg, "tooltip");
+
+ if(!(component instanceof UIRichMessages)){
+ return;
+ }
+
+ uiMessages = (UIRichMessages)component;
+
+ boolean isTooltip = getUtils().isBooleanAttribute(uiMessages, "tooltip");
- boolean showSummary = uiMsg.isShowSummary();
+ boolean showSummary = uiMessages.isShowSummary();
- boolean showDetail = uiMsg.isShowDetail();
+ boolean showDetail = uiMessages.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;
+ labelClass = labelClass == null ? "rich-messages-label" :
"rich-messages-label " + labelClass;
+ if(uiMessages.isWroteTable()){
+ writer.startElement(HTML.td_ELEM, component);
+ }
- writer.startElement(HTML.td_ELEM, component);
+ writer.startElement(HTML.SPAN_ELEM, uiMessages);
- getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE,classes);
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE,labelClass);
getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, labelStyle);
if(facesMsg != null){
+
if(isTooltip){
- title = (String) uiMsg.getAttributes().get("title");
+
+ 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){
@@ -170,39 +226,91 @@
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);
+ writer.endElement(HTML.SPAN_ELEM);
+ if(uiMessages.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 = (UIRichMessages)component;
+ UIRichMessages uiMessages = null;
+
+
+ if(!(component instanceof UIRichMessages)){
+ return;
+ }
+
+ uiMessages = (UIRichMessages)component;
+
if(uiMessages.isWroteTable()){
-
writer.startElement(HTML.td_ELEM, component);
+ }else{
+ writer.startElement(HTML.SPAN_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);
+ 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);
+ renderChild(context, markerFacet);
+ if(uiMessages.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;
+
+ 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 renderHeaderFacet(ResponseWriter writer, FacesContext context,
UIRichMessages uiMessages) throws IOException{
@@ -238,6 +346,7 @@
writer.endElement(HTML.TR_ELEMENT);
writer.endElement(HTML.THEAD_ELEMENT);
}
+
}
protected Class getComponentClass() {
Modified:
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 2007-07-25
11:33:03 UTC (rev 1838)
+++
trunk/sandbox/ui/message/src/main/resources/org/richfaces/renderkit/html/css/msgs.css 2007-07-25
12:43:47 UTC (rev 1839)
@@ -9,3 +9,7 @@
.rich-messages-header{
}
+
+SPAN.rich-messages-marker, SPAN.rich-messages-marker *{
+ vertical-align: middle;
+}