KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > component > ext > HtmlForm


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

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 JavaDoc COMPONENT_TYPE = "com.icesoft.faces.HtmlForm";
49     public static final String JavaDoc RENDERER_TYPE = "com.icesoft.faces.Form";
50     private static final boolean DEFAULT_PARITALSUBMIT = false;
51     private Boolean JavaDoc partialSubmit = null;
52     private String JavaDoc enabledOnUserRole = null;
53     private String JavaDoc renderedOnUserRole = null;
54     private String JavaDoc styleClass = null;
55
56     public HtmlForm() {
57         super();
58         setRendererType(RENDERER_TYPE);
59     }
60
61     /**
62      * <p>Set the value of the <code>partialSubmit</code> property.</p>
63      */

64     public void setPartialSubmit(boolean partialSubmit) {
65         this.partialSubmit = Boolean.valueOf(partialSubmit);
66     }
67
68
69     /**
70      * <p>Return the value of the <code>partialSubmit</code> property.</p>
71      */

72     public boolean getPartialSubmit() {
73         if (partialSubmit != null) {
74             return partialSubmit.booleanValue();
75         }
76         ValueBinding vb = getValueBinding("partialSubmit");
77         Boolean JavaDoc boolVal =
78                 vb != null ? (Boolean JavaDoc) vb.getValue(getFacesContext()) : null;
79         return boolVal != null ? boolVal.booleanValue() : DEFAULT_PARITALSUBMIT;
80     }
81
82     /**
83      * <p>Set the value of the <code>enabledOnUserRole</code> property.</p>
84      */

85     public void setEnabledOnUserRole(String JavaDoc enabledOnUserRole) {
86         this.enabledOnUserRole = enabledOnUserRole;
87     }
88
89
90     /**
91      * <p>Return the value of the <code>enabledOnUserRole</code> property.</p>
92      */

93     public String JavaDoc getEnabledOnUserRole() {
94         if (enabledOnUserRole != null) {
95             return enabledOnUserRole;
96         }
97         ValueBinding vb = getValueBinding("enabledOnUserRole");
98         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
99     }
100
101     /**
102      * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
103      */

104     public void setRenderedOnUserRole(String JavaDoc renderedOnUserRole) {
105         this.renderedOnUserRole = renderedOnUserRole;
106     }
107
108
109     /**
110      * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
111      */

112     public String JavaDoc getRenderedOnUserRole() {
113         if (renderedOnUserRole != null) {
114             return renderedOnUserRole;
115         }
116         ValueBinding vb = getValueBinding("renderedOnUserRole");
117         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
118     }
119
120
121     /**
122      * <p>Return the value of the <code>rendered</code> property.</p>
123      */

124     public boolean isRendered() {
125         if (!Util.isRenderedOnUserRole(this)) {
126             return false;
127         }
128         return super.isRendered();
129     }
130
131     private String JavaDoc autocomplete;
132
133     /**
134      * <p>Set the value of the <code>autocomplete</code> property.</p>
135      */

136     public void setAutocomplete(String JavaDoc autocomplete) {
137         this.autocomplete = autocomplete;
138     }
139
140     /**
141      * <p>Return the value of the <code>autocomplete</code> property.</p>
142      */

143     public String JavaDoc getAutocomplete() {
144         if (autocomplete != null) {
145             return autocomplete;
146         }
147         ValueBinding vb = getValueBinding("autocomplete");
148         return vb != null ? (String JavaDoc) vb.getValue(getFacesContext()) : null;
149     }
150
151     /**
152      * <p>Set the value of the <code>styleClass</code> property.</p>
153      */

154     public void setStyleClass(String JavaDoc styleClass) {
155         this.styleClass = styleClass;
156     }
157
158     /**
159      * <p>Return the value of the <code>styleClass</code> property.</p>
160      */

161     public String JavaDoc getStyleClass() {
162         return Util.getQualifiedStyleClass(this,
163                 styleClass,
164                 CSS_DEFAULT.FORM_STYLE_CLASS,
165                 "styleClass");
166     }
167
168     /**
169      * <p>Gets the state of the instance as a <code>Serializable</code>
170      * Object.</p>
171      */

172     public Object JavaDoc saveState(FacesContext context) {
173         Object JavaDoc values[] = new Object JavaDoc[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 JavaDoc) (values));
180     }
181
182     /**
183      * <p>Perform any processing required to restore the state from the entries
184      * in the state Object.</p>
185      */

186     public void restoreState(FacesContext context, Object JavaDoc state) {
187         Object JavaDoc values[] = (Object JavaDoc[]) state;
188         super.restoreState(context, values[0]);
189         partialSubmit = (Boolean JavaDoc) values[1];
190         enabledOnUserRole = (String JavaDoc) values[2];
191         renderedOnUserRole = (String JavaDoc) values[3];
192         autocomplete = (String JavaDoc) values[4];
193     }
194 }
195
196
197
Popular Tags