1 16 package com.blandware.atleap.webapp.form.core; 17 18 import com.blandware.atleap.webapp.taglib.core.grid.util.FilterConditions; 19 import org.apache.struts.action.ActionErrors; 20 import org.apache.struts.action.ActionMapping; 21 import org.apache.struts.action.ActionMessage; 22 23 import javax.servlet.http.HttpServletRequest ; 24 25 35 public class StringFilterForm extends BaseFilterForm { 36 37 protected String firstCondition = FilterConditions.STRING_CONTAINS; 38 protected String firstValue = ""; 39 protected String secondCondition = FilterConditions.CONDITION_NOT_SET; 40 protected String secondValue = null; 41 protected String logicCopula = FilterConditions.LOGIC_COPULA_AND; 42 43 44 47 public StringFilterForm() { 48 } 49 50 55 public String getFirstCondition() { 56 return firstCondition; 57 } 58 59 64 public void setFirstCondition(String firstCondition) { 65 this.firstCondition = firstCondition; 66 } 67 68 73 public String getFirstValue() { 74 return firstValue; 75 } 76 77 82 public void setFirstValue(String firstValue) { 83 this.firstValue = firstValue; 84 } 85 86 91 public String getSecondCondition() { 92 return secondCondition; 93 } 94 95 100 public void setSecondCondition(String secondCondition) { 101 this.secondCondition = secondCondition; 102 } 103 104 109 public String getSecondValue() { 110 return secondValue; 111 } 112 113 118 public void setSecondValue(String secondValue) { 119 this.secondValue = secondValue; 120 } 121 122 127 public String getLogicCopula() { 128 return logicCopula; 129 } 130 131 136 public void setLogicCopula(String logicCopula) { 137 this.logicCopula = logicCopula; 138 } 139 140 146 public void reset(ActionMapping mapping, HttpServletRequest request) { 147 super.reset(mapping, request); 148 this.firstCondition = FilterConditions.STRING_CONTAINS; 149 this.firstValue = ""; 150 this.secondCondition = FilterConditions.CONDITION_NOT_SET; 151 this.secondValue = null; 152 this.clearFilter = null; 153 logicCopula = FilterConditions.LOGIC_COPULA_AND; 154 } 155 156 163 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 164 ActionErrors errors = super.validate(mapping, request); 165 166 if ( clearFilter == null ) { 167 168 boolean notSet = secondCondition.equalsIgnoreCase(FilterConditions.CONDITION_NOT_SET); 169 boolean isNull = secondCondition.equalsIgnoreCase(FilterConditions.OBJECT_IS_NULL); 170 boolean isNotNull = secondCondition.equalsIgnoreCase(FilterConditions.OBJECT_IS_NOT_NULL); 171 172 if ( !notSet && !isNull && !isNotNull ) { 173 if ( secondValue == null || secondValue.length() == 0 ) { 174 errors.add("secondValue", new ActionMessage("core.grid.filter.errors.secondValueRequired")); 175 } 176 } 177 } else { 178 errors = new ActionErrors(); 179 } 180 return errors; 181 } 182 183 184 } | Popular Tags |