1 16 package org.apache.cocoon.faces.taglib.html; 17 18 import org.apache.cocoon.faces.FacesUtils; 19 import org.apache.cocoon.faces.taglib.UIComponentTag; 20 import org.apache.commons.lang.BooleanUtils; 21 22 import javax.faces.FacesException; 23 import javax.faces.component.UIComponent; 24 import javax.faces.component.UIMessages; 25 26 29 public class MessagesTag extends UIComponentTag { 30 31 private String globalOnly; 32 private String showDetail; 33 private String showSummary; 34 private String errorClass; 35 private String errorStyle; 36 private String fatalClass; 37 private String fatalStyle; 38 private String infoClass; 39 private String infoStyle; 40 private String layout; 41 private String style; 42 private String styleClass; 43 private String title; 44 private String tooltip; 45 private String warnClass; 46 private String warnStyle; 47 48 49 public void setGlobalOnly(String globalOnly) { 50 this.globalOnly = globalOnly; 51 } 52 53 public void setShowDetail(String showDetail) { 54 this.showDetail = showDetail; 55 } 56 57 public void setShowSummary(String showSummary) { 58 this.showSummary = showSummary; 59 } 60 61 public void setErrorClass(String errorClass) { 62 this.errorClass = errorClass; 63 } 64 65 public void setErrorStyle(String errorStyle) { 66 this.errorStyle = errorStyle; 67 } 68 69 public void setFatalClass(String fatalClass) { 70 this.fatalClass = fatalClass; 71 } 72 73 public void setFatalStyle(String fatalStyle) { 74 this.fatalStyle = fatalStyle; 75 } 76 77 public void setInfoClass(String infoClass) { 78 this.infoClass = infoClass; 79 } 80 81 public void setInfoStyle(String infoStyle) { 82 this.infoStyle = infoStyle; 83 } 84 85 public void setLayout(String layout) { 86 this.layout = layout; 87 } 88 89 public void setStyle(String style) { 90 this.style = style; 91 } 92 93 public void setStyleClass(String styleClass) { 94 this.styleClass = styleClass; 95 } 96 97 public void setTitle(String title) { 98 this.title = title; 99 } 100 101 public void setTooltip(String tooltip) { 102 this.tooltip = tooltip; 103 } 104 105 public void setWarnClass(String warnClass) { 106 this.warnClass = warnClass; 107 } 108 109 public void setWarnStyle(String warnStyle) { 110 this.warnStyle = warnStyle; 111 } 112 113 114 public String getRendererType() { 115 return "javax.faces.Messages"; 116 } 117 118 public String getComponentType() { 119 return "javax.faces.HtmlMessages"; 120 } 121 122 123 protected void setProperties(UIComponent component) { 124 super.setProperties(component); 125 126 UIMessages messages = null; 127 try { 128 messages = (UIMessages) component; 129 } catch (ClassCastException cce) { 130 throw new FacesException("Tag <" + getClass().getName() + "> expected UIMessages. " + 131 "Got <" + component.getClass().getName() + ">"); 132 } 133 134 if (globalOnly != null) { 135 if (FacesUtils.isExpression(globalOnly)) { 136 messages.setValueBinding("globalOnly", createValueBinding(globalOnly)); 137 } else { 138 messages.setGlobalOnly(BooleanUtils.toBoolean(globalOnly)); 139 } 140 } 141 142 if (showDetail != null) { 143 if (FacesUtils.isExpression(showDetail)) { 144 messages.setValueBinding("showDetail", createValueBinding(showDetail)); 145 } else { 146 messages.setShowDetail(BooleanUtils.toBoolean(showDetail)); 147 } 148 } 149 150 if (showSummary != null) { 151 if (FacesUtils.isExpression(showSummary)) { 152 messages.setValueBinding("showSummary", createValueBinding(showSummary)); 153 } else { 154 messages.setShowSummary(BooleanUtils.toBoolean(showSummary)); 155 } 156 } 157 158 setProperty(component, "errorClass", errorClass); 159 setProperty(component, "errorStyle", errorStyle); 160 setProperty(component, "fatalClass", fatalClass); 161 setProperty(component, "fatalStyle", fatalStyle); 162 setProperty(component, "infoClass", infoClass); 163 setProperty(component, "infoStyle", infoStyle); 164 setProperty(component, "layout", layout); 165 setProperty(component, "style", style); 166 setProperty(component, "styleClass", styleClass); 167 setProperty(component, "title", title); 168 169 setBooleanProperty(component, "tooltip", tooltip); 170 171 setProperty(component, "warnClass", warnClass); 172 setProperty(component, "warnStyle", warnStyle); 173 } 174 175 public void recycle() { 176 super.recycle(); 177 globalOnly = null; 178 showDetail = null; 179 showSummary = null; 180 errorClass = null; 181 errorStyle = null; 182 fatalClass = null; 183 fatalStyle = null; 184 infoClass = null; 185 infoStyle = null; 186 layout = null; 187 style = null; 188 styleClass = null; 189 title = null; 190 tooltip = null; 191 warnClass = null; 192 warnStyle = null; 193 } 194 } 195 | Popular Tags |