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 WriteComponent extends UIOutput { 31 32 33 35 36 39 public WriteComponent() { 40 41 super(); 42 setRendererType("org.apache.struts.faces.Write"); 43 44 } 45 46 47 49 50 53 private boolean filter = true; 54 private boolean filterSet = false; 55 56 57 60 private String style = null; 61 62 63 66 private String styleClass = null; 67 68 69 71 72 75 public String getFamily() { 76 77 return "org.apache.struts.faces.Write"; 78 79 } 80 81 82 85 public boolean isFilter() { 86 87 if (filterSet) { 88 return filter; 89 } 90 ValueBinding vb = getValueBinding("filter"); 91 if (vb != null) { 92 Boolean value = (Boolean ) vb.getValue(getFacesContext()); 93 if (null == value) { 94 return filter; 95 } 96 return value.booleanValue(); 97 } else { 98 return filter; 99 } 100 101 } 102 103 104 109 public void setFilter(boolean filter) { 110 111 this.filter = filter; 112 this.filterSet = true; 113 114 } 115 116 117 120 public String getStyle() { 121 122 ValueBinding vb = getValueBinding("style"); 123 if (vb != null) { 124 return (String ) vb.getValue(getFacesContext()); 125 } else { 126 return style; 127 } 128 129 } 130 131 132 137 public void setStyle(String style) { 138 139 this.style = style; 140 141 } 142 143 144 147 public String getStyleClass() { 148 149 ValueBinding vb = getValueBinding("styleClass"); 150 if (vb != null) { 151 return (String ) vb.getValue(getFacesContext()); 152 } else { 153 return styleClass; 154 } 155 156 } 157 158 159 164 public void setStyleClass(String styleClass) { 165 166 this.styleClass = styleClass; 167 168 } 169 170 171 173 174 180 public void restoreState(FacesContext context, Object state) { 181 182 Object values[] = (Object []) state; 183 super.restoreState(context, values[0]); 184 filter = ((Boolean ) values[1]).booleanValue(); 185 filterSet = ((Boolean ) values[2]).booleanValue(); 186 style = (String ) values[3]; 187 styleClass = (String ) values[4]; 188 189 } 190 191 192 197 public Object saveState(FacesContext context) { 198 199 Object values[] = new Object [5]; 200 values[0] = super.saveState(context); 201 values[1] = filter ? Boolean.TRUE : Boolean.FALSE; 202 values[2] = filterSet ? Boolean.TRUE : Boolean.FALSE; 203 values[3] = style; 204 values[4] = styleClass; 205 return values; 206 207 } 208 209 210 } 211 | Popular Tags |