1 package com.dotmarketing.portlets.structure.struts; 2 3 import java.util.List ; 4 5 import javax.servlet.http.HttpServletRequest ; 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 fieldName; 21 private String fieldType; 22 private String fieldRelationType; 23 private String fieldContentlet; 24 private boolean required; 25 private String velocityVarName; 26 private int sortOrder; 27 private String values; 28 private String regexCheck; 29 private List freeContentletFieldsName; 30 private List freeContentletFieldsValue; 31 private String validation; 32 private String hint; 33 private String defaultValue; 34 private String dataType; 35 private boolean indexed = false; 36 private boolean listed = false; 37 38 public String getFieldContentlet() { 39 return fieldContentlet; 40 } 41 42 public void setFieldContentlet(String fieldContentlet) { 43 this.fieldContentlet = fieldContentlet; 44 } 45 46 public String getFieldName() { 47 return fieldName; 48 } 49 50 public void setFieldName(String fieldName) { 51 this.fieldName = fieldName; 52 } 53 54 public String getFieldRelationType() { 55 return fieldRelationType; 56 } 57 58 public void setFieldRelationType(String fieldRelationType) { 59 this.fieldRelationType = fieldRelationType; 60 } 61 62 public String getFieldType() { 63 return fieldType; 64 } 65 66 public void setFieldType(String 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 getRegexCheck() { 79 return regexCheck; 80 } 81 82 public void setRegexCheck(String 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 getValues() { 111 return values; 112 } 113 114 public void setValues(String values) { 115 this.values = values; 116 } 117 118 public String getVelocityVarName() { 119 return velocityVarName; 120 } 121 122 public void setVelocityVarName(String velocityVarName) { 123 this.velocityVarName = velocityVarName; 124 } 125 126 public List getFreeContentletFieldsName() { 127 return freeContentletFieldsName; 128 } 129 130 public void setFreeContentletFieldsName(List freeContentletFieldsName) { 131 this.freeContentletFieldsName = freeContentletFieldsName; 132 } 133 134 public List getFreeContentletFieldsValue() { 135 return freeContentletFieldsValue; 136 } 137 138 public void setFreeContentletFieldsValue(List freeContentletFieldsvalue) { 139 this.freeContentletFieldsValue = freeContentletFieldsvalue; 140 } 141 142 145 public String getDefaultValue() { 146 return defaultValue; 147 } 148 149 152 public void setDefaultValue(String defaultValue) { 153 this.defaultValue = defaultValue; 154 } 155 156 159 public String getHint() { 160 return hint; 161 } 162 163 166 public void setHint(String hint) { 167 this.hint = hint; 168 } 169 170 173 public String getDataType() { 174 return dataType; 175 } 176 177 180 public void setDataType(String dataType) { 181 this.dataType = dataType; 182 } 183 184 187 public String getValidation() { 188 if (!UtilMethods.isSet(validation)) { 189 return regexCheck; 190 } 191 return validation; 192 } 193 194 197 public void setValidation(String 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 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 |