| 1 9 10 package com.quikj.application.communicator.applications.webtalk.controller; 11 12 import javax.servlet.http.*; 13 import org.apache.struts.action.*; 14 import org.apache.struts.validator.*; 15 import org.apache.commons.validator.*; 16 17 21 public class ValidatorUtil 22 { 23 24 25 public ValidatorUtil() 26 { 27 } 28 29 public static boolean validateStringRequiredIf( Object bean, 31 ValidatorAction va, 32 Field field, 33 ActionErrors errors, 34 HttpServletRequest request) 35 { 36 DynaValidatorForm form = (DynaValidatorForm)bean; 37 38 String required_if = field.getVarValue("submit"); 40 41 if (((String )form.get("submit")).equals(required_if) == true) 43 { 44 String value = (String )form.get(field.getProperty()); 46 47 if (value == null) 48 { 49 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 50 return false; 51 } 52 53 if (value.trim().length() <= 0) 54 { 55 errors.add(field.getKey(), Resources.getActionError(request, va, field)); 56 return false; 57 } 58 } 59 60 return true; 61 } 62 63 } 64 | Popular Tags |