Author: abelevich
Date: 2007-07-27 07:39:12 -0400 (Fri, 27 Jul 2007)
New Revision: 1882
Modified:
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
Log:
add isPassed attribute, fix messages rendering
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-27
09:21:00 UTC (rev 1881)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2007-07-27
11:39:12 UTC (rev 1882)
@@ -4,6 +4,7 @@
package org.richfaces.component;
import javax.faces.component.UIMessages;
+import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxOutput;
@@ -25,10 +26,13 @@
private boolean isIteratorLayout = false;
-// private String headerLocation = "left";
+ private boolean isPassed = false;
-
+ public boolean isPassed() {
+ return isPassed;
+ }
+
public abstract void setHeaderLocation(String headerLocation);
public abstract String getHeaderLocation();
@@ -64,4 +68,9 @@
new IllegalArgumentException();
}
}
+
+ public void decode(FacesContext context) {
+ isPassed = true;
+ super.decode(context);
+ }
}
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-27
09:21:00 UTC (rev 1881)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java 2007-07-27
11:39:12 UTC (rev 1882)
@@ -94,12 +94,11 @@
public void renderComponentUI(ResponseWriter writer, FacesContext context, UIComponent
component, Iterator messagesIter) throws IOException{
-
-
String layout = null;
String var = null;
+
UIRichMessages uiMessages = (UIRichMessages)component;
@@ -107,13 +106,12 @@
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);
- renderComponentOuterStyles(uiMessages, context, writer);
writer.startElement("tbody", uiMessages);
uiMessages.setWroteTable(true);
@@ -126,13 +124,13 @@
}
writer.startElement(HTML.SPAN_ELEM, component);
- getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
uiMessages.getClientId(context));
+
uiMessages.setIteratorLayout(true);
}else if((layout != null) && (layout.equals("list"))){
writer.startElement("dl", component);
- getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
uiMessages.getClientId(context));
+
renderComponentOuterStyles(uiMessages, context, writer);
}
@@ -162,9 +160,13 @@
}else{
Map requestMap = context.getExternalContext().getRequestMap();
+ Object value = requestMap.get(var);
requestMap.put(var, facesMsg);
renderChildren(context, uiMessages);
+ if(value != null){
+ requestMap.put(var, value);
+ }
}
}
@@ -334,8 +336,6 @@
public void renderHeaderFacet(ResponseWriter writer, FacesContext context,
UIRichMessages uiMessages, UIComponent headerFacet) throws IOException{
- UIComponent facet = null;
-
String headerClass = null;
String headerStyle = null;
@@ -345,28 +345,24 @@
headerStyle = (String)uiMessages.getAttributes().get("headerStyle");
-// if(uiMessages.getFacet("header") != null){
-//
-// facet = uiMessages.getFacet("header");
-//
-// if(!facet.isRendered()){
-// return;
-// }
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, headerClass);
+ getUtils().writeAttribute(writer,HTML.style_ATTRIBUTE, headerStyle);
- getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, headerClass);
- getUtils().writeAttribute(writer,HTML.style_ATTRIBUTE, headerStyle);
-
- renderChild(context, facet);
-// }
+ renderChild(context, headerFacet);
+
}
public void renderBody(UIComponent component, ResponseWriter writer, FacesContext
context, Iterator messagesIter) throws IOException{
UIRichMessages uiMessages = (UIRichMessages)component;
-
+
+ String clientId = uiMessages.getClientId(context);
+
String headerLocation = uiMessages.getHeaderLocation();
+ boolean isPassed = uiMessages.isPassed();
+
if(headerLocation == null){
return;
}
@@ -383,6 +379,7 @@
}
writer.startElement("table", uiMessages);
+ getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,clientId);
writer.startElement("tbody", uiMessages);
if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_BOTTOM)){
@@ -395,14 +392,13 @@
writer.endElement(HTML.td_ELEM);
writer.endElement(HTML.TR_ELEMENT);
- if(headerFacet != null && !headerFacet.isRendered()){
+ if(headerFacet != null && headerFacet.isRendered() && isPassed){
-
writer.startElement(HTML.TR_ELEMENT, uiMessages);
writer.startElement(HTML.td_ELEM, uiMessages);
-
+
renderHeaderFacet(writer, context, uiMessages, headerFacet);
-
+
writer.endElement(HTML.td_ELEM);
writer.endElement(HTML.TR_ELEMENT);
@@ -410,13 +406,13 @@
}else if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_TOP)){
- if(headerFacet != null && !headerFacet.isRendered()){
+ if(headerFacet != null && headerFacet.isRendered() && isPassed){
writer.startElement(HTML.TR_ELEMENT, uiMessages);
writer.startElement(HTML.td_ELEM, uiMessages);
-
+
renderHeaderFacet(writer, context, uiMessages, headerFacet);
-
+
writer.endElement(HTML.td_ELEM);
writer.endElement(HTML.TR_ELEMENT);
@@ -434,10 +430,12 @@
writer.startElement(HTML.TR_ELEMENT, uiMessages);
- if(headerFacet != null && !headerFacet.isRendered()){
+ if(headerFacet != null && headerFacet.isRendered()&& isPassed){
writer.startElement(HTML.td_ELEM, uiMessages);
+
renderHeaderFacet(writer, context, uiMessages, headerFacet);
+
writer.endElement(HTML.td_ELEM);
}
@@ -459,14 +457,16 @@
writer.endElement(HTML.td_ELEM);
- if(headerFacet != null && !headerFacet.isRendered()){
+ if(headerFacet != null && headerFacet.isRendered() && isPassed){
writer.startElement(HTML.td_ELEM, uiMessages);
- renderHeaderFacet(writer, context, uiMessages,headerFacet);
+
+ renderHeaderFacet(writer, context, uiMessages, headerFacet);
+
writer.endElement(HTML.td_ELEM);
}
-
+
writer.endElement(HTML.TR_ELEMENT);
}