Author: abelevich
Date: 2007-07-26 04:44:05 -0400 (Thu, 26 Jul 2007)
New Revision: 1862
Modified:
trunk/sandbox/ui/message/src/main/config/component/message.xml
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 headerLocation support
Modified: trunk/sandbox/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-26 01:09:38 UTC
(rev 1861)
+++ trunk/sandbox/ui/message/src/main/config/component/message.xml 2007-07-26 08:44:05 UTC
(rev 1862)
@@ -236,7 +236,7 @@
<defaultvalue>"list"</defaultvalue>
</property>
- <property>
+ <property attachedstate="true">
<name>headerLocation</name>
<classname>java.lang.String</classname>
<defaultvalue>"top"</defaultvalue>
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-26
01:09:38 UTC (rev 1861)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2007-07-26
08:44:05 UTC (rev 1862)
@@ -13,11 +13,26 @@
*/
public abstract class UIRichMessages extends UIMessages implements AjaxOutput {
+ public static String HEADER_LOCATION_LEFT = "left";
+
+ public static String HEADER_LOCATION_TOP = "top";
+
+ public static String HEADER_LOCATION_BOTTOM = "bottom";
+
+ public static String HEADER_LOCATION_RIGHT = "right";
+
private boolean wroteTable = false;
private boolean isIteratorLayout = false;
+// private String headerLocation = "left";
+
+
+ public abstract void setHeaderLocation(String headerLocation);
+
+ public abstract String getHeaderLocation();
+
public boolean isWroteTable() {
return wroteTable;
}
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-26
01:09:38 UTC (rev 1861)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java 2007-07-26
08:44:05 UTC (rev 1862)
@@ -76,15 +76,11 @@
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- Iterator messagesIter = null;
-
String forIds = null;
- String layout = null;
+ Iterator messagesIter = null;
- String var = null;
-
UIRichMessages uiMessages = (UIRichMessages)component;
if(uiMessages.isGlobalOnly()){
@@ -93,6 +89,20 @@
messagesIter = getMessageIterator(context, forIds, component);
+ renderBody(component, writer, context, 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"))){
@@ -101,7 +111,8 @@
getUtils().writeAttribute(writer, HTML.cellpadding_ATTRIBUTE, "0");
getUtils().writeAttribute(writer, HTML.cellspacing_ATTRIBUTE, "0");
- renderHeaderFacet(writer, context, uiMessages);
+// renderHeaderFacet(writer, context, uiMessages);
+
renderComponentOuterStyles(uiMessages, context, writer);
writer.startElement("tbody", uiMessages);
uiMessages.setWroteTable(true);
@@ -159,18 +170,20 @@
}
if(!uiMessages.isIteratorLayout()){
+
if(uiMessages.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 {
@@ -319,7 +332,7 @@
- public void renderHeaderFacet(ResponseWriter writer, FacesContext context,
UIRichMessages uiMessages) throws IOException{
+ public void renderHeaderFacet(ResponseWriter writer, FacesContext context,
UIRichMessages uiMessages, UIComponent headerFacet) throws IOException{
UIComponent facet = null;
@@ -332,27 +345,134 @@
headerStyle = (String)uiMessages.getAttributes().get("headerStyle");
- if(uiMessages.getFacet("header") != null){
-
- facet = uiMessages.getFacet("header");
+// if(uiMessages.getFacet("header") != null){
+//
+// facet = uiMessages.getFacet("header");
+//
+// if(!facet.isRendered()){
+// return;
+// }
- if(!facet.isRendered()){
- return;
- }
+ getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, headerClass);
+ getUtils().writeAttribute(writer,HTML.style_ATTRIBUTE, headerStyle);
+
+ renderChild(context, facet);
+// }
+
+ }
+
+ public void renderBody(UIComponent component, ResponseWriter writer, FacesContext
context, Iterator messagesIter) throws IOException{
+
+ UIRichMessages uiMessages = (UIRichMessages)component;
+
+ String headerLocation = uiMessages.getHeaderLocation();
+
+ if(headerLocation == null){
+ return;
+ }
+
+ UIComponent headerFacet = null;
+
+ UIComponent passedHeaderFacet = uiMessages.getFacet("passedHeader");
+ UIComponent commonHeaderFacet = uiMessages.getFacet("header");
+
+ if(passedHeaderFacet != null && !messagesIter.hasNext()){
+ headerFacet = passedHeaderFacet;
+ }else if(commonHeaderFacet != null){
+ headerFacet = commonHeaderFacet;
+ }
+
+ writer.startElement("table", uiMessages);
+ writer.startElement("tbody", uiMessages);
+
+ if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_BOTTOM)){
- 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);
+ renderComponentUI(writer, context, uiMessages, messagesIter);
+
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+
+ if(headerFacet != null && !headerFacet.isRendered()){
- renderChild(context, facet);
+
+ 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);
+
+ }
+
+ }else if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_TOP)){
+
+ if(headerFacet != null && !headerFacet.isRendered()){
+
+ 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);
+
+ }
+
+ writer.startElement(HTML.TR_ELEMENT, uiMessages);
+ writer.startElement(HTML.td_ELEM, uiMessages);
+
+ renderComponentUI(writer, context, uiMessages, messagesIter);
+
writer.endElement(HTML.td_ELEM);
writer.endElement(HTML.TR_ELEMENT);
- writer.endElement(HTML.THEAD_ELEMENT);
+
+ }else if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_LEFT)){
+
+ writer.startElement(HTML.TR_ELEMENT, uiMessages);
+
+ if(headerFacet != null && !headerFacet.isRendered()){
+
+ writer.startElement(HTML.td_ELEM, uiMessages);
+ renderHeaderFacet(writer, context, uiMessages, headerFacet);
+ writer.endElement(HTML.td_ELEM);
+
+ }
+
+ writer.startElement(HTML.td_ELEM, uiMessages);
+
+ renderComponentUI(writer, context, uiMessages, messagesIter);
+
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+
+
+ }else if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_RIGHT)){
+
+ writer.startElement(HTML.TR_ELEMENT, uiMessages);
+ writer.startElement(HTML.td_ELEM, uiMessages);
+
+ renderComponentUI(writer, context, uiMessages, messagesIter);
+
+ writer.endElement(HTML.td_ELEM);
+
+ if(headerFacet != null && !headerFacet.isRendered()){
+
+ writer.startElement(HTML.td_ELEM, uiMessages);
+ renderHeaderFacet(writer, context, uiMessages,headerFacet);
+ writer.endElement(HTML.td_ELEM);
+
+ }
+
+ writer.endElement(HTML.TR_ELEMENT);
+
}
+
+ writer.endElement("tbody");
+ writer.endElement("table");
}