1 6 7 package com.quikj.application.communicator.applications.webtalk.controller; 8 9 import javax.servlet.http.*; 10 import org.apache.struts.action.*; 11 import org.apache.struts.validator.*; 12 import org.apache.commons.validator.*; 13 14 18 public class GroupWizardValidator 19 { 20 21 22 public GroupWizardValidator() 23 { 24 } 25 26 public static boolean validateCompanyNickname( 27 Object bean, 28 ValidatorAction va, 29 Field field, 30 ActionErrors errors, 31 HttpServletRequest request) 32 { 33 DynaValidatorForm form = (DynaValidatorForm)bean; 34 35 String validate_if = field.getVarValue("submit"); 37 38 if (((String )form.get("submit")).equals(validate_if) == true) 40 { 41 String name = field.getProperty(); 43 44 if (name.equals("companyNickname") == false) 45 { 46 return false; 47 } 48 49 String value = ((String )form.get(name)).trim(); 51 52 if (value.equals("all") == true) 53 { 54 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 56 57 return false; 58 } 59 60 if (DataCheckUtility.followsTableIdRules(value) == false) 61 { 62 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 63 64 return false; 65 } 66 } 67 68 return true; 69 } 70 71 72 public static boolean validateCompanyUrl( 73 Object bean, 74 ValidatorAction va, 75 Field field, 76 ActionErrors errors, 77 HttpServletRequest request) 78 { 79 DynaValidatorForm form = (DynaValidatorForm)bean; 80 81 String validate_if = field.getVarValue("submit"); 83 84 if (((String )form.get("submit")).equals(validate_if) == true) 86 { 87 String name = field.getProperty(); 89 90 if (name.equals("companyUrl") == false) 91 { 92 return false; 93 } 94 95 String value = ((String )form.get(name)).trim(); 97 98 if (value.length() < ("http://".length() + 5)) 99 { 100 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 101 102 return false; 103 } 104 } 105 106 return true; 107 } 108 109 public static boolean validateGroupName( 110 Object bean, 111 ValidatorAction va, 112 Field field, 113 ActionErrors errors, 114 HttpServletRequest request) 115 { 116 DynaValidatorForm form = (DynaValidatorForm)bean; 117 118 String validate_if = field.getVarValue("submit"); 120 121 if (((String )form.get("submit")).equals(validate_if) == true) 123 { 124 String name = field.getProperty(); 126 127 if (name.equals("groupName") == false) 128 { 129 return false; 130 } 131 132 String value = ((String )form.get(name)).trim(); 134 135 if (DataCheckUtility.followsTableIdRules(value) == false) 136 { 137 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 138 139 return false; 140 } 141 } 142 143 return true; 144 } 145 146 147 public static boolean validateFeatureMaximums( 148 Object bean, 149 ValidatorAction va, 150 Field field, 151 ActionErrors errors, 152 HttpServletRequest request) 153 { 154 DynaValidatorForm form = (DynaValidatorForm)bean; 155 156 String validate_if = field.getVarValue("submit"); 158 159 if (((String )form.get("submit")).equals(validate_if) == true) 161 { 162 Integer value = (Integer )form.get(field.getProperty()); 164 165 if (value == null) 166 { 167 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 168 return false; 169 } 170 171 if (value.intValue() <= 0) 172 { 173 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 174 return false; 175 } 176 177 } 178 179 return true; 180 } 181 182 } 183 | Popular Tags |