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 HtmlComponent extends UIOutput { 31 32 33 35 36 39 public HtmlComponent() { 40 41 super(); 42 setRendererType("org.apache.struts.faces.Html"); 43 44 } 45 46 47 49 50 53 private boolean locale = true; 54 private boolean localeSet = false; 55 56 57 60 private boolean xhtml = false; 61 private boolean xhtmlSet = false; 62 63 64 66 67 70 public String getFamily() { 71 72 return "org.apache.struts.faces.Html"; 73 74 } 75 76 77 80 public boolean isLocale() { 81 82 if (localeSet) { 83 return locale; 84 } 85 ValueBinding vb = getValueBinding("locale"); 86 if (vb != null) { 87 Boolean value = (Boolean ) vb.getValue(getFacesContext()); 88 if (null == value) { 89 return locale; 90 } 91 return value.booleanValue(); 92 } else { 93 return locale; 94 } 95 96 } 97 98 99 104 public void setLocale(boolean locale) { 105 106 this.locale = locale; 107 this.localeSet = true; 108 109 } 110 111 112 115 public boolean isXhtml() { 116 117 if (xhtmlSet) { 118 return xhtml; 119 } 120 ValueBinding vb = getValueBinding("xhtml"); 121 if (vb != null) { 122 Boolean value = (Boolean ) vb.getValue(getFacesContext()); 123 if (null == value) { 124 return xhtml; 125 } 126 return value.booleanValue(); 127 } else { 128 return xhtml; 129 } 130 131 } 132 133 134 139 public void setXhtml(boolean xhtml) { 140 141 this.xhtml = xhtml; 142 this.xhtmlSet = true; 143 144 } 145 146 147 149 150 156 public void restoreState(FacesContext context, Object state) { 157 158 Object values[] = (Object []) state; 159 super.restoreState(context, values[0]); 160 locale = ((Boolean ) values[1]).booleanValue(); 161 localeSet = ((Boolean ) values[2]).booleanValue(); 162 xhtml = ((Boolean ) values[3]).booleanValue(); 163 xhtmlSet = ((Boolean ) values[4]).booleanValue(); 164 165 } 166 167 168 173 public Object saveState(FacesContext context) { 174 175 Object values[] = new Object [5]; 176 values[0] = super.saveState(context); 177 values[1] = locale ? Boolean.TRUE : Boolean.FALSE; 178 values[2] = localeSet ? Boolean.TRUE : Boolean.FALSE; 179 values[3] = xhtml ? Boolean.TRUE : Boolean.FALSE; 180 values[4] = xhtmlSet ? Boolean.TRUE : Boolean.FALSE; 181 return values; 182 183 } 184 185 186 } 187 | Popular Tags |