1 33 34 package com.icesoft.faces.component.ext; 35 36 import com.icesoft.faces.component.CSS_DEFAULT; 37 import com.icesoft.faces.component.IceExtended; 38 import com.icesoft.faces.component.ext.taglib.Util; 39 40 import javax.faces.context.FacesContext; 41 import javax.faces.el.ValueBinding; 42 43 44 public class HtmlForm 45 extends javax.faces.component.html.HtmlForm 46 implements IceExtended { 47 48 public static final String COMPONENT_TYPE = "com.icesoft.faces.HtmlForm"; 49 public static final String RENDERER_TYPE = "com.icesoft.faces.Form"; 50 private static final boolean DEFAULT_PARITALSUBMIT = false; 51 private Boolean partialSubmit = null; 52 private String enabledOnUserRole = null; 53 private String renderedOnUserRole = null; 54 private String styleClass = null; 55 56 public HtmlForm() { 57 super(); 58 setRendererType(RENDERER_TYPE); 59 } 60 61 64 public void setPartialSubmit(boolean partialSubmit) { 65 this.partialSubmit = Boolean.valueOf(partialSubmit); 66 } 67 68 69 72 public boolean getPartialSubmit() { 73 if (partialSubmit != null) { 74 return partialSubmit.booleanValue(); 75 } 76 ValueBinding vb = getValueBinding("partialSubmit"); 77 Boolean boolVal = 78 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 79 return boolVal != null ? boolVal.booleanValue() : DEFAULT_PARITALSUBMIT; 80 } 81 82 85 public void setEnabledOnUserRole(String enabledOnUserRole) { 86 this.enabledOnUserRole = enabledOnUserRole; 87 } 88 89 90 93 public String getEnabledOnUserRole() { 94 if (enabledOnUserRole != null) { 95 return enabledOnUserRole; 96 } 97 ValueBinding vb = getValueBinding("enabledOnUserRole"); 98 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 99 } 100 101 104 public void setRenderedOnUserRole(String renderedOnUserRole) { 105 this.renderedOnUserRole = renderedOnUserRole; 106 } 107 108 109 112 public String getRenderedOnUserRole() { 113 if (renderedOnUserRole != null) { 114 return renderedOnUserRole; 115 } 116 ValueBinding vb = getValueBinding("renderedOnUserRole"); 117 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 118 } 119 120 121 124 public boolean isRendered() { 125 if (!Util.isRenderedOnUserRole(this)) { 126 return false; 127 } 128 return super.isRendered(); 129 } 130 131 private String autocomplete; 132 133 136 public void setAutocomplete(String autocomplete) { 137 this.autocomplete = autocomplete; 138 } 139 140 143 public String getAutocomplete() { 144 if (autocomplete != null) { 145 return autocomplete; 146 } 147 ValueBinding vb = getValueBinding("autocomplete"); 148 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 149 } 150 151 154 public void setStyleClass(String styleClass) { 155 this.styleClass = styleClass; 156 } 157 158 161 public String getStyleClass() { 162 return Util.getQualifiedStyleClass(this, 163 styleClass, 164 CSS_DEFAULT.FORM_STYLE_CLASS, 165 "styleClass"); 166 } 167 168 172 public Object saveState(FacesContext context) { 173 Object values[] = new Object [5]; 174 values[0] = super.saveState(context); 175 values[1] = partialSubmit; 176 values[2] = enabledOnUserRole; 177 values[3] = renderedOnUserRole; 178 values[4] = autocomplete; 179 return ((Object ) (values)); 180 } 181 182 186 public void restoreState(FacesContext context, Object state) { 187 Object values[] = (Object []) state; 188 super.restoreState(context, values[0]); 189 partialSubmit = (Boolean ) values[1]; 190 enabledOnUserRole = (String ) values[2]; 191 renderedOnUserRole = (String ) values[3]; 192 autocomplete = (String ) values[4]; 193 } 194 } 195 196 197 | Popular Tags |