1 16 17 package org.apache.struts.faces.taglib; 18 19 20 import javax.faces.component.UIComponent; 21 import javax.faces.el.ValueBinding; 22 import javax.faces.webapp.UIComponentTag; 23 24 25 32 33 public abstract class AbstractFacesTag extends UIComponentTag { 34 35 36 38 39 43 protected String bundle = null; 44 45 public void setBundle(String bundle) { 46 this.bundle = bundle; 47 } 48 49 50 53 protected String style = null; 54 55 public void setStyle(String style) { 56 this.style = style; 57 } 58 59 60 63 protected String styleClass = null; 64 65 public void setStyleClass(String styleClass) { 66 this.styleClass = styleClass; 67 } 68 69 70 73 protected String value = null; 74 75 public void setValue(String value) { 76 this.value = value; 77 } 78 79 80 82 83 87 public abstract String getComponentType(); 88 89 90 94 public abstract String getRendererType(); 95 96 97 100 public void release() { 101 102 super.release(); 103 this.bundle = null; 104 this.style = null; 105 this.styleClass = null; 106 this.value = null; 107 108 } 109 110 111 113 114 119 protected void setProperties(UIComponent component) { 120 121 super.setProperties(component); 122 setStringAttribute(component, "bundle", bundle); 123 setStringAttribute(component, "style", style); 124 setStringAttribute(component, "styleClass", styleClass); 125 setStringAttribute(component, "value", value); 126 127 } 128 129 130 132 133 149 protected void setBooleanAttribute(UIComponent component, 150 String name, String value) { 151 152 if (value == null) { 153 return; 154 } 155 if (isValueReference(value)) { 156 ValueBinding vb = 157 getFacesContext().getApplication().createValueBinding(value); 158 component.setValueBinding(name, vb); 159 } else { 160 component.getAttributes().put(name, Boolean.valueOf(value)); 161 } 162 163 } 164 165 166 182 protected void setIntegerAttribute(UIComponent component, 183 String name, String value) { 184 185 if (value == null) { 186 return; 187 } 188 if (isValueReference(value)) { 189 ValueBinding vb = 190 getFacesContext().getApplication().createValueBinding(value); 191 component.setValueBinding(name, vb); 192 } else { 193 component.getAttributes().put(name, Integer.valueOf(value)); 194 } 195 196 } 197 198 199 213 protected void setStringAttribute(UIComponent component, 214 String name, String value) { 215 216 if (value == null) { 217 return; 218 } 219 if (isValueReference(value)) { 220 ValueBinding vb = 221 getFacesContext().getApplication().createValueBinding(value); 222 component.setValueBinding(name, vb); 223 } else { 224 component.getAttributes().put(name, value); 225 } 226 227 } 228 } 229 | Popular Tags |