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 NumberFilterForm extends BaseFilterForm { 36 37 protected String firstCondition = FilterConditions.NUMBER_EQUAL; 38 protected String firstValue = "0"; 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 NumberFilterForm() { 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 84 public void setFirstValue(String firstValue) { 85 this.firstValue = firstValue; 86 } 87 88 93 public String getSecondCondition() { 94 return secondCondition; 95 } 96 97 102 public void setSecondCondition(String secondCondition) { 103 this.secondCondition = secondCondition; 104 } 105 106 111 public String getSecondValue() { 112 return secondValue; 113 } 114 115 122 public void setSecondValue(String secondValue) { 123 this.secondValue = secondValue; 124 } 125 126 131 public String getLogicCopula() { 132 return logicCopula; 133 } 134 135 140 public void setLogicCopula(String logicCopula) { 141 this.logicCopula = logicCopula; 142 } 143 144 150 public void reset(ActionMapping mapping, HttpServletRequest request) { 151 super.reset(mapping, request); 152 this.firstCondition = FilterConditions.NUMBER_EQUAL; 153 this.firstValue = "0"; 154 this.secondCondition = FilterConditions.CONDITION_NOT_SET; 155 this.secondValue = null; 156 this.clearFilter = null; 157 logicCopula = FilterConditions.LOGIC_COPULA_AND; 158 } 159 160 167 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 168 ActionErrors errors = super.validate(mapping, request); 169 170 if ( clearFilter == null ) { 171 172 boolean notSet = secondCondition.equalsIgnoreCase(FilterConditions.CONDITION_NOT_SET); 173 boolean isNull = secondCondition.equalsIgnoreCase(FilterConditions.OBJECT_IS_NULL); 174 boolean isNotNull = secondCondition.equalsIgnoreCase(FilterConditions.OBJECT_IS_NOT_NULL); 175 176 if ( !notSet && !isNull && !isNotNull ) { 177 if ( secondValue == null || secondValue.length() == 0 ) { 178 errors.add("secondValue", new ActionMessage("core.grid.filter.errors.secondValueRequired")); 179 } 180 } 181 } else { 182 errors = new ActionErrors(); 183 } 184 return errors; 185 } 186 187 188 } | Popular Tags |