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.UIMessage; 25 26 29 public class MessageTag extends UIComponentTag { 30 31 private String _for; 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 setFor(String _for) { 50 this._for = _for; 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.Message"; 116 } 117 118 public String getComponentType() { 119 return "javax.faces.HtmlMessage"; 120 } 121 122 123 protected void setProperties(UIComponent component) { 124 super.setProperties(component); 125 126 UIMessage message = null; 127 try { 128 message = (UIMessage) component; 129 } catch (ClassCastException cce) { 130 throw new FacesException("Tag <" + getClass().getName() + "> expected UIMessage. " + 131 "Got <" + component.getClass().getName() + ">"); 132 } 133 134 if (_for != null) { 135 if (FacesUtils.isExpression(_for)) { 137 message.setValueBinding("_for", createValueBinding(_for)); 138 } else { 139 message.setFor(_for); 140 } 141 } 142 143 if (showDetail != null) { 144 if (FacesUtils.isExpression(showDetail)) { 145 message.setValueBinding("showDetail", createValueBinding(showDetail)); 146 } else { 147 message.setShowDetail(BooleanUtils.toBoolean(showDetail)); 148 } 149 } 150 151 if (showSummary != null) { 152 if (FacesUtils.isExpression(showSummary)) { 153 message.setValueBinding("showSummary", createValueBinding(showSummary)); 154 } else { 155 message.setShowSummary(BooleanUtils.toBoolean(showSummary)); 156 } 157 } 158 159 setProperty(component, "errorClass", errorClass); 160 setProperty(component, "errorStyle", errorStyle); 161 setProperty(component, "fatalClass", fatalClass); 162 setProperty(component, "fatalStyle", fatalStyle); 163 setProperty(component, "infoClass", infoClass); 164 setProperty(component, "infoStyle", infoStyle); 165 setProperty(component, "layout", layout); 166 setProperty(component, "style", style); 167 setProperty(component, "styleClass", styleClass); 168 setProperty(component, "title", title); 169 170 setBooleanProperty(component, "tooltip", tooltip); 171 172 setProperty(component, "warnClass", warnClass); 173 setProperty(component, "warnStyle", warnStyle); 174 } 175 176 public void recycle() { 177 super.recycle(); 178 _for = null; 179 showDetail = null; 180 showSummary = null; 181 errorClass = null; 182 errorStyle = null; 183 fatalClass = null; 184 fatalStyle = null; 185 infoClass = null; 186 infoStyle = null; 187 layout = null; 188 style = null; 189 styleClass = null; 190 title = null; 191 tooltip = null; 192 warnClass = null; 193 warnStyle = null; 194 } 195 } 196 | Popular Tags |