KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > structure > struts > FieldForm


1 package com.dotmarketing.portlets.structure.struts;
2
3 import java.util.List JavaDoc;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6
7 import org.apache.struts.Globals;
8 import org.apache.struts.action.ActionErrors;
9 import org.apache.struts.action.ActionMapping;
10 import org.apache.struts.action.ActionMessage;
11 import org.apache.struts.validator.ValidatorForm;
12
13 import com.dotmarketing.util.UtilMethods;
14
15 public class FieldForm extends ValidatorForm {
16     
17     private static final long serialVersionUID = 1L;
18     private long inode;
19     private long structureInode;
20     private String JavaDoc fieldName;
21     private String JavaDoc fieldType;
22     private String JavaDoc fieldRelationType;
23     private String JavaDoc fieldContentlet;
24     private boolean required;
25     private String JavaDoc velocityVarName;
26     private int sortOrder;
27     private String JavaDoc values;
28     private String JavaDoc regexCheck;
29     private List JavaDoc freeContentletFieldsName;
30     private List JavaDoc freeContentletFieldsValue;
31     private String JavaDoc validation;
32     private String JavaDoc hint;
33     private String JavaDoc defaultValue;
34     private String JavaDoc dataType;
35     private boolean indexed = false;
36     private boolean listed = false;
37         
38     public String JavaDoc getFieldContentlet() {
39         return fieldContentlet;
40     }
41
42     public void setFieldContentlet(String JavaDoc fieldContentlet) {
43         this.fieldContentlet = fieldContentlet;
44     }
45
46     public String JavaDoc getFieldName() {
47         return fieldName;
48     }
49
50     public void setFieldName(String JavaDoc fieldName) {
51         this.fieldName = fieldName;
52     }
53
54     public String JavaDoc getFieldRelationType() {
55         return fieldRelationType;
56     }
57
58     public void setFieldRelationType(String JavaDoc fieldRelationType) {
59         this.fieldRelationType = fieldRelationType;
60     }
61
62     public String JavaDoc getFieldType() {
63         return fieldType;
64     }
65
66     public void setFieldType(String JavaDoc fieldType) {
67         this.fieldType = fieldType;
68     }
69
70     public long getInode() {
71         return inode;
72     }
73
74     public void setInode(long inode) {
75         this.inode = inode;
76     }
77
78     public String JavaDoc getRegexCheck() {
79         return regexCheck;
80     }
81
82     public void setRegexCheck(String JavaDoc regexCheck) {
83         this.regexCheck = regexCheck;
84     }
85
86     public boolean isRequired() {
87         return required;
88     }
89     
90     public void setRequired(boolean required) {
91         this.required = required;
92     }
93
94     public int getSortOrder() {
95         return sortOrder;
96     }
97
98     public void setSortOrder(int sortOrder) {
99         this.sortOrder = sortOrder;
100     }
101
102     public long getStructureInode() {
103         return structureInode;
104     }
105
106     public void setStructureInode(long structureInode) {
107         this.structureInode = structureInode;
108     }
109
110     public String JavaDoc getValues() {
111         return values;
112     }
113
114     public void setValues(String JavaDoc values) {
115         this.values = values;
116     }
117
118     public String JavaDoc getVelocityVarName() {
119         return velocityVarName;
120     }
121
122     public void setVelocityVarName(String JavaDoc velocityVarName) {
123         this.velocityVarName = velocityVarName;
124     }
125     
126     public List JavaDoc getFreeContentletFieldsName() {
127         return freeContentletFieldsName;
128     }
129
130     public void setFreeContentletFieldsName(List JavaDoc freeContentletFieldsName) {
131         this.freeContentletFieldsName = freeContentletFieldsName;
132     }
133
134     public List JavaDoc getFreeContentletFieldsValue() {
135         return freeContentletFieldsValue;
136     }
137
138     public void setFreeContentletFieldsValue(List JavaDoc freeContentletFieldsvalue) {
139         this.freeContentletFieldsValue = freeContentletFieldsvalue;
140     }
141     
142     /**
143      * @return Returns the defaultValue.
144      */

145     public String JavaDoc getDefaultValue() {
146         return defaultValue;
147     }
148
149     /**
150      * @param defaultValue The defaultValue to set.
151      */

152     public void setDefaultValue(String JavaDoc defaultValue) {
153         this.defaultValue = defaultValue;
154     }
155
156     /**
157      * @return Returns the hint.
158      */

159     public String JavaDoc getHint() {
160         return hint;
161     }
162
163     /**
164      * @param hint The hint to set.
165      */

166     public void setHint(String JavaDoc hint) {
167         this.hint = hint;
168     }
169
170     /**
171      * @return Returns the dataType.
172      */

173     public String JavaDoc getDataType() {
174         return dataType;
175     }
176
177     /**
178      * @param dataType The dataType to set.
179      */

180     public void setDataType(String JavaDoc dataType) {
181         this.dataType = dataType;
182     }
183
184     /**
185      * @return Returns the validation.
186      */

187     public String JavaDoc getValidation() {
188         if (!UtilMethods.isSet(validation)) {
189             return regexCheck;
190         }
191         return validation;
192     }
193
194     /**
195      * @param validation The validation to set.
196      */

197     public void setValidation(String JavaDoc validation) {
198         this.validation = validation;
199     }
200
201     public boolean isIndexed() {
202         return indexed;
203     }
204
205     public void setIndexed(boolean indexed) {
206         this.indexed = indexed;
207     }
208
209     public boolean isListed() {
210         return listed;
211     }
212
213     public void setListed(boolean listed) {
214         this.listed = listed;
215     }
216
217     public ActionErrors validate(ActionMapping arg0, HttpServletRequest JavaDoc arg1) {
218         ActionErrors ae = new ActionErrors();
219         ae = super.validate(arg0,arg1);
220         if(fieldType.equals("select") || fieldType.equals("radio") || fieldType.equals("checkbox"))
221         {
222             if (!UtilMethods.isSet(values))
223             {
224                 ae.add(Globals.ERROR_KEY,new ActionMessage("message.field.values"));
225             }
226         }
227         if(!fieldType.equals("image") && !fieldType.equals("link") && !fieldType.equals("file"))
228         {
229             if (!UtilMethods.isSet(dataType))
230             {
231                 ae.add(Globals.ERROR_KEY,new ActionMessage("message.field.dataType"));
232             }
233         }
234         return ae;
235     }
236 }
237
Popular Tags