Author: abelevich
Date: 2007-07-30 09:57:48 -0400 (Mon, 30 Jul 2007)
New Revision: 1923
Removed:
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
Log:
rename classes
Deleted:
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-30
13:52:52 UTC (rev 1922)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageBaseRenderer.java 2007-07-30
13:57:48 UTC (rev 1923)
@@ -1,311 +0,0 @@
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-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.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;
-
-/**
- * @author Anton Belevich
- *
- */
-//TODO nick - anton - please review our naming conventions:
-
-//Naming Conventions
-//During the development we should follow the naming convention for all project stuff.
The rules are defined below:
-//
-//
-//By default, a geterator expects the following structure for Java classes :
-//
-//<prefix>.component.Abstract<Name> ia an optional abstract superclass for a
JSF component. To avoid manual writing for EL-enabled getters/setters,
saveState/restoreState methods, listener-related methods etc, a developer can create an
abstract class, and a generator creates the implementation.
-//<prefix>.component.UI<Name> is a Base component class. It can be generated
from the abstract superclass or created by a developer.
-//<prefix>.component.<markup>.<Markup><RendererName>renderer-specific
generated component( where the markup is a render-kit specific generation name, such as
html | xml | wml ). In addition to the UI Component class, contains Java Bean
getter/setter methods for renderer-specific attributes. This class is generated by CDK.
-//<prefix>.<Name> - JSF UI component-type. Can be provided in the
configuration or calculated from a component class name.
-//<prefix>.<Markup><RendererName> - renderer-specific JSF
component-type. Can be provided in the configuration or calculated from the renderer name.
-//<prefix>.renderkit.<RendererName>RendererBase - optional Renderer
superclass, implements methods from template renderer used by generated. Created by a
component developer.
-//<prefix>.renderkit.<markup>.<RendererName>Renderer is a generated
renderer.
-//<prefix>.<RendererName>Renderer - JSF renderer-type. Can be provided in the
configuration or calculated from a renderer name.
-//<prefix>.<Markup><RendererName>.xml is a template for generating the
renderer class. jspx - like syntax is used. Provided by a component developer.
-//<prefix>.taglib.<RendererName>Tag - JSP tag class.
-//<prefix>.taglib.<RendererName>TagHandler is a facelets tag handler class.
-//<renderername> - JSP/facelets tag name.
-//For components, that uses JSF events :
-//
-//<prefix>.event.<Event>Event is a event class. Provided by component a
developer.
-//<prefix>.event.<Event>Listener is an event listener interface. Can be
generated by CDK
-//process<Event> is an event processing method name in a listener interface.
-//<prefix>.event.<Event>Source - is an interface for an event processing
component ( with methods add<Event>Listener(<Event>Listener listener ) ,
remove<Event>Listener.... )
-//<prefix>.event.<Event>EventWrapper - wrapper class. Uses for binding
listener's EL-expression in user's beans.
-//<prefix>.taglib.<Event>ListenerTag - JSP tag class for a creating listener
instance. A parent tag must creates component implementing Source interface.
-//<prefix>.taglib.<Event>ListenerTagHandler is a facelets tag class for
creation of listener instance.
-//
-//
-//Definitions that are used in this structure ( uppercase symbols means Java names
notation, for name "foo" <name> mean "foo", and <Name> -
"Foo" ):
-//
-//<prefix>
-//is a common library name ( for example, base JSF components use <javax.faces>
prefix ). Value for prefix get from an abstract component package or a renderer template
path.
-//<name>
-//is a name for base component ( for UIInput component <name> is "input"
). Value for a component name generator can got from UI... or Abstract... class name.
-//<markup>
-//is a render-kit generated a content name, "html" for HTML/XHTML pages,
"wml" for mobile content etc. It must be provided in the render-kit description
by ant task or maven POM. By default, "html" is used
-//<rendererName>
-//- name of renderer for concreting a visual component implementation, e.g.
"commandButton" , "panelGroup" etc. A generator can take rendererName
from a template file name.
-//<event>
-//is a name for Faces Event ( "action" for all ActionSource components like
UICommand ). Can be provided in the component configuration, or got from the implemented
...Source interface.
-
-//TODO nick - anton - please consider using jspx templates
-public abstract class RichMessageBaseRenderer extends HeaderResourcesRendererBase{
-
- 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";
-
-
- protected Iterator getMessageIterator(FacesContext context, String forClientId,
UIComponent component) throws IOException{
-
- Iterator msgIter = null;
-
- if(forClientId != null && forClientId.length() != 0){
-
- UIComponent result = findForComponent(context, forClientId,component);
- if (result == null) {
- msgIter = CollectionUtils.EMPTY_COLLECTION.iterator();
- } else {
- msgIter = context.getMessages(result.getClientId(context));
- }
- }else{
- msgIter = context.getMessages(null);
- msgIter = context.getMessages();
- }
-
- 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 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){
- return null;
- }
-
- UIComponent result = null;
- UIComponent parent = component;
-
- while(parent != null){
- result = parent.findComponent(forClientId);
-
- if(result != null){
- break;
- }
- 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);
- }
- }
-
- return result;
- }
-
- protected UIComponent findComponentBelow(UIComponent startComponent, String
forClientId){
-
- UIComponent retComp = null;
-
- if(startComponent.getChildCount() == 0){
- return null;
- }
-
- List children = startComponent.getChildren();
-
- for(int i = 0, size = children.size(); i < size; i++){
- UIComponent comp = (UIComponent) children.get(i);
-
- if(comp instanceof NamingContainer){
- retComp = comp.findComponent(forClientId);
- }
-
- if(retComp == null){
- if(comp.getChildCount() > 0){
- retComp = findComponentBelow(comp, forClientId);
- }
- }
-
- if(retComp != null)
- break;
- }
-
- return retComp;
- };
-
- public abstract void renderMarkerHtml(UIComponent component, UIComponent markerFacet,
FacesContext context, ResponseWriter writer,
- String markerClass, String markerStyle) throws IOException;
-
- 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;
-}
Deleted:
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-30
13:52:52 UTC (rev 1922)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessageHtmlBaseRenderer.java 2007-07-30
13:57:48 UTC (rev 1923)
@@ -1,234 +0,0 @@
-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.UIMessage;
-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{
- 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 msgIter = null;
-
- 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);
- writer.startElement(HTML.SPAN_ELEM, msgComponent);
- getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,
msgComponent.getClientId(context));
-
- if(!msgIter.hasNext() && msgComponent.isPassed()){
-
- encodingUIContent(msgComponent, context, null);
-
- }else if(msgIter.hasNext() ){
-
- FacesMessage message = (FacesMessage)msgIter.next();
- encodingUIContent(msgComponent, context, message);
-
- }
-
- writer.endElement(HTML.SPAN_ELEM);
- }
- }
-
- protected void encodingUIContent(UIRichMessage uiMsg, FacesContext context, FacesMessage
facesMsg) throws IOException{
-
- ResponseWriter writer = context.getResponseWriter();
-
- outerStyles(uiMsg, context, writer, facesMsg);
- renderMarkerFacet(uiMsg,context, writer,facesMsg);
- renderLabel(uiMsg, context, writer, facesMsg);
-
-
- }
-
- public void renderOuterStyles(UIComponent component, FacesContext context,
ResponseWriter writer,String outerStyle, String outerClass) throws IOException{
-
- 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 ? 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 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;
-
- getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, classes);
- getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, markerStyle);
-
- renderChild(context, marker);
-
- writer.endElement(HTML.SPAN_ELEM);
-
- }
-
- 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 = null;
-
- if(!(component instanceof UIRichMessage)){
- return;
- }
-
- 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-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(passLabel != null){
- 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
Deleted:
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-30
13:52:52 UTC (rev 1922)
+++
trunk/sandbox/ui/message/src/main/java/org/richfaces/renderkit/html/RichMessagesHtmlBaseRenderer.java 2007-07-30
13:57:48 UTC (rev 1923)
@@ -1,512 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit.html;
-
-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;
-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.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 {
-
- String forIds = null;
-
- Iterator messagesIter = null;
-
-
- UIRichMessages uiMessages = (UIRichMessages)component;
-
- if(uiMessages.isGlobalOnly()){
- forIds = "";
- }
-
- 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"))){
-
- writer.startElement("table", component);
-
- getUtils().writeAttribute(writer, HTML.cellpadding_ATTRIBUTE, "0");
- getUtils().writeAttribute(writer, HTML.cellspacing_ATTRIBUTE, "0");
-
-// renderComponentOuterStyles(uiMessages, context, writer);
-
- writer.startElement("tbody", uiMessages);
- uiMessages.setWroteTable(true);
-
- }else if((layout != null) && (layout.equals("iterator"))){
-
- var = (String)uiMessages.getAttributes().get("var");
- if(var == null){
- FacesException e = new FacesException(new IllegalArgumentException("var
attribute is not defined"));
- throw e;
- }
-
- writer.startElement(HTML.SPAN_ELEM, component);
-
- uiMessages.setIteratorLayout(true);
-
- }else if((layout != null) && (layout.equals("list"))){
-
- writer.startElement("dl", component);
-
-// renderComponentOuterStyles(uiMessages, context, writer);
-
- }
-
- if(log.isInfoEnabled()){
- log.info("start render messages");
- }
-
- while(messagesIter.hasNext()){
-
- FacesMessage facesMsg = (FacesMessage)(messagesIter.next());
-
- if(!uiMessages.isIteratorLayout()){
-
- if(uiMessages.isWroteTable()){
- writer.startElement(HTML.TR_ELEMENT, component);
- }else{
- writer.startElement("dt", 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("dt");
- }
-
- }else{
-
- Map requestMap = context.getExternalContext().getRequestMap();
- Object value = requestMap.get(var);
- requestMap.put(var, facesMsg);
-
- try {
-
- if(log.isInfoEnabled()){
- log.info("start render children of " + uiMessages.getClientId(context) +
" component");
- }
-
- renderChildren(context, uiMessages);
- } finally {
-
- if(value != null){
- requestMap.put(var, value);
- }
-
- }
-
- }
-
- }
-
- 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 {
-
- String summary = null;
-
- String detail = null;
-
- String title = null;
-
- UIRichMessages uiMessages = null;
-
-
- if(!(component instanceof UIRichMessages)){
- return;
- }
-
- uiMessages = (UIRichMessages)component;
-
- if(log.isInfoEnabled()){
- log.info("start render label HTML");
- }
-
- boolean isTooltip = getUtils().isBooleanAttribute(uiMessages, "tooltip");
-
- boolean showSummary = uiMessages.isShowSummary();
-
- boolean showDetail = uiMessages.isShowDetail();
-
- if(facesMsg != null){
- summary = (null != (summary = facesMsg.getSummary())) ? summary : "";
- detail = (null != (detail = facesMsg.getDetail())) ? detail : "";
- }
-
- labelClass = labelClass == null ? "rich-messages-label" :
"rich-messages-label " + labelClass;
-
- if(uiMessages.isWroteTable()){
- writer.startElement(HTML.td_ELEM, component);
- }
-
- writer.startElement(HTML.SPAN_ELEM, uiMessages);
-
- getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE,labelClass);
- getUtils().writeAttribute(writer, HTML.style_ATTRIBUTE, labelStyle);
-
- if(facesMsg != null){
-
- if(isTooltip){
-
- 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){
- 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);
-
- 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 = null;
-
-
- if(!(component instanceof UIRichMessages)){
- return;
- }
-
- if(log.isInfoEnabled()){
- log.info("start render marker HTML: " + markerFacet.getClientId(context));
- }
-
- 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);
-
- 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;
-
- if(log.isInfoEnabled()){
- log.info("start render component outer styles: " +
uiMessages.getClientId(context));
- }
-
- 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, UIComponent headerFacet) throws IOException{
-
- String headerClass = null;
-
- String headerStyle = null;
-
-
- headerClass = (String)uiMessages.getAttributes().get("headerClass");
-
- headerStyle = (String)uiMessages.getAttributes().get("headerStyle");
-
- getUtils().writeAttribute(writer, HTML.class_ATTRIBUTE, headerClass);
- getUtils().writeAttribute(writer,HTML.style_ATTRIBUTE, headerStyle);
-
- 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;
- }
-
- 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);
- getUtils().writeAttribute(writer, HTML.id_ATTRIBUTE,clientId);
- renderComponentOuterStyles(component, context, writer);
-
- writer.startElement("tbody", uiMessages);
-
- if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_BOTTOM)){
-
- 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);
-
- 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);
-
- }
-
- }else if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_TOP)){
-
- 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);
-
- }
-
- 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);
-
- }else if(headerLocation.equals(UIRichMessages.HEADER_LOCATION_LEFT)){
-
- writer.startElement(HTML.TR_ELEMENT, uiMessages);
-
- if(headerFacet != null && headerFacet.isRendered()&& isPassed){
-
- 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() && isPassed){
-
- 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");
-
- }
-
- protected Class getComponentClass() {
- return UIMessages.class;
- }
-
-}