1 16 17 package org.apache.struts.faces.component; 18 19 20 import javax.faces.component.UIOutput; 21 import javax.faces.context.FacesContext; 22 import javax.faces.el.ValueBinding; 23 24 25 29 30 public class MessageComponent extends UIOutput { 31 32 33 35 36 39 public MessageComponent() { 40 41 super(); 42 setRendererType("org.apache.struts.faces.Message"); 43 44 } 45 46 47 49 50 53 private String bundle = null; 54 55 56 59 private boolean filter = true; 60 private boolean filterSet = false; 61 62 63 66 private String key = null; 67 68 69 72 private String style = null; 73 74 75 78 private String styleClass = null; 79 80 81 83 84 87 public String getBundle() { 88 89 ValueBinding vb = getValueBinding("bundle"); 90 if (vb != null) { 91 return (String ) vb.getValue(getFacesContext()); 92 } else { 93 return bundle; 94 } 95 96 } 97 98 99 104 public void setBundle(String bundle) { 105 106 this.bundle = bundle; 107 108 } 109 110 111 114 public String getFamily() { 115 116 return "org.apache.struts.faces.Message"; 117 118 } 119 120 121 124 public boolean isFilter() { 125 126 if (filterSet) { 127 return filter; 128 } 129 ValueBinding vb = getValueBinding("filter"); 130 if (vb != null) { 131 Boolean value = (Boolean ) vb.getValue(getFacesContext()); 132 if (null == value) { 133 return filter; 134 } 135 return value.booleanValue(); 136 } else { 137 return filter; 138 } 139 140 } 141 142 143 148 public void setFilter(boolean filter) { 149 150 this.filter = filter; 151 this.filterSet = true; 152 153 } 154 155 156 159 public String getKey() { 160 161 ValueBinding vb = getValueBinding("key"); 162 if (vb != null) { 163 return (String ) vb.getValue(getFacesContext()); 164 } else { 165 return key; 166 } 167 168 } 169 170 171 176 public void setKey(String key) { 177 178 this.key = key; 179 180 } 181 182 183 186 public String getStyle() { 187 188 ValueBinding vb = getValueBinding("style"); 189 if (vb != null) { 190 return (String ) vb.getValue(getFacesContext()); 191 } else { 192 return style; 193 } 194 195 } 196 197 198 203 public void setStyle(String style) { 204 205 this.style = style; 206 207 } 208 209 210 213 public String getStyleClass() { 214 215 ValueBinding vb = getValueBinding("styleClass"); 216 if (vb != null) { 217 return (String ) vb.getValue(getFacesContext()); 218 } else { 219 return styleClass; 220 } 221 222 } 223 224 225 230 public void setStyleClass(String styleClass) { 231 232 this.styleClass = styleClass; 233 234 } 235 236 237 239 240 246 public void restoreState(FacesContext context, Object state) { 247 248 Object values[] = (Object []) state; 249 super.restoreState(context, values[0]); 250 bundle = (String ) values[1]; 251 filter = ((Boolean ) values[2]).booleanValue(); 252 filterSet = ((Boolean ) values[3]).booleanValue(); 253 key = (String ) values[4]; 254 style = (String ) values[5]; 255 styleClass = (String ) values[6]; 256 257 } 258 259 260 265 public Object saveState(FacesContext context) { 266 267 Object values[] = new Object [7]; 268 values[0] = super.saveState(context); 269 values[1] = bundle; 270 values[2] = filter ? Boolean.TRUE : Boolean.FALSE; 271 values[3] = filterSet ? Boolean.TRUE : Boolean.FALSE; 272 values[4] = key; 273 values[5] = style; 274 values[6] = styleClass; 275 return values; 276 277 } 278 279 280 } 281 | Popular Tags |