001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.ext;
035:
036: import com.icesoft.faces.component.CSS_DEFAULT;
037: import com.icesoft.faces.component.IceExtended;
038: import com.icesoft.faces.component.ext.taglib.Util;
039:
040: import javax.faces.context.FacesContext;
041: import javax.faces.el.ValueBinding;
042:
043: public class HtmlForm extends javax.faces.component.html.HtmlForm
044: implements IceExtended {
045:
046: public static final String COMPONENT_TYPE = "com.icesoft.faces.HtmlForm";
047: public static final String RENDERER_TYPE = "com.icesoft.faces.Form";
048: private static final boolean DEFAULT_PARITALSUBMIT = false;
049: private Boolean partialSubmit = null;
050: private String enabledOnUserRole = null;
051: private String renderedOnUserRole = null;
052: private String styleClass = null;
053:
054: public HtmlForm() {
055: super ();
056: setRendererType(RENDERER_TYPE);
057: }
058:
059: /**
060: * <p>Set the value of the <code>partialSubmit</code> property.</p>
061: */
062: public void setPartialSubmit(boolean partialSubmit) {
063: this .partialSubmit = Boolean.valueOf(partialSubmit);
064: }
065:
066: /**
067: * <p>Return the value of the <code>partialSubmit</code> property.</p>
068: */
069: public boolean getPartialSubmit() {
070: if (partialSubmit != null) {
071: return partialSubmit.booleanValue();
072: }
073: ValueBinding vb = getValueBinding("partialSubmit");
074: Boolean boolVal = vb != null ? (Boolean) vb
075: .getValue(getFacesContext()) : null;
076: return boolVal != null ? boolVal.booleanValue()
077: : DEFAULT_PARITALSUBMIT;
078: }
079:
080: /**
081: * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
082: */
083: public void setEnabledOnUserRole(String enabledOnUserRole) {
084: this .enabledOnUserRole = enabledOnUserRole;
085: }
086:
087: /**
088: * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
089: */
090: public String getEnabledOnUserRole() {
091: if (enabledOnUserRole != null) {
092: return enabledOnUserRole;
093: }
094: ValueBinding vb = getValueBinding("enabledOnUserRole");
095: return vb != null ? (String) vb.getValue(getFacesContext())
096: : null;
097: }
098:
099: /**
100: * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
101: */
102: public void setRenderedOnUserRole(String renderedOnUserRole) {
103: this .renderedOnUserRole = renderedOnUserRole;
104: }
105:
106: /**
107: * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
108: */
109: public String getRenderedOnUserRole() {
110: if (renderedOnUserRole != null) {
111: return renderedOnUserRole;
112: }
113: ValueBinding vb = getValueBinding("renderedOnUserRole");
114: return vb != null ? (String) vb.getValue(getFacesContext())
115: : null;
116: }
117:
118: /**
119: * <p>Return the value of the <code>rendered</code> property.</p>
120: */
121: public boolean isRendered() {
122: if (!Util.isRenderedOnUserRole(this )) {
123: return false;
124: }
125: return super .isRendered();
126: }
127:
128: private String autocomplete;
129:
130: /**
131: * <p>Set the value of the <code>autocomplete</code> property.</p>
132: */
133: public void setAutocomplete(String autocomplete) {
134: this .autocomplete = autocomplete;
135: }
136:
137: /**
138: * <p>Return the value of the <code>autocomplete</code> property.</p>
139: */
140: public String getAutocomplete() {
141: if (autocomplete != null) {
142: return autocomplete;
143: }
144: ValueBinding vb = getValueBinding("autocomplete");
145: return vb != null ? (String) vb.getValue(getFacesContext())
146: : null;
147: }
148:
149: /**
150: * <p>Set the value of the <code>styleClass</code> property.</p>
151: */
152: public void setStyleClass(String styleClass) {
153: this .styleClass = styleClass;
154: }
155:
156: /**
157: * <p>Return the value of the <code>styleClass</code> property.</p>
158: */
159: public String getStyleClass() {
160: return Util.getQualifiedStyleClass(this , styleClass,
161: CSS_DEFAULT.FORM_STYLE_CLASS, "styleClass");
162: }
163:
164: /**
165: * <p>Gets the state of the instance as a <code>Serializable</code>
166: * Object.</p>
167: */
168: public Object saveState(FacesContext context) {
169: Object values[] = new Object[5];
170: values[0] = super .saveState(context);
171: values[1] = partialSubmit;
172: values[2] = enabledOnUserRole;
173: values[3] = renderedOnUserRole;
174: values[4] = autocomplete;
175: return ((Object) (values));
176: }
177:
178: /**
179: * <p>Perform any processing required to restore the state from the entries
180: * in the state Object.</p>
181: */
182: public void restoreState(FacesContext context, Object state) {
183: Object values[] = (Object[]) state;
184: super .restoreState(context, values[0]);
185: partialSubmit = (Boolean) values[1];
186: enabledOnUserRole = (String) values[2];
187: renderedOnUserRole = (String) values[3];
188: autocomplete = (String) values[4];
189: }
190: }
|