Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 7 package com.inversoft.verge.util; 8 9 10 import java.io.Serializable ; 11 import java.util.List ; 12 13 import javax.servlet.http.HttpServletRequest ; 14 15 import com.inversoft.error.BasicError; 16 import com.inversoft.error.ErrorList; 17 import com.inversoft.error.PropertyError; 18 19 20 30 public class RequestContext implements Serializable { 31 32 35 public static final String ERROR_LIST_KEY = "inversoftErrors"; 36 37 40 private ErrorList errors; 41 42 46 private boolean valid; 47 48 49 52 public RequestContext(HttpServletRequest request) { 53 errors = (ErrorList) request.getAttribute(ERROR_LIST_KEY); 54 if (errors == null) { 55 errors = new ErrorList(); 56 request.setAttribute(ERROR_LIST_KEY, errors); 57 } 58 } 59 60 61 67 public void addError(BasicError error) { 68 errors.addError(error); 69 } 70 71 79 public void addError(PropertyError error) { 80 errors.addError(error); 81 } 82 83 88 public boolean hasErrors() { 89 return !errors.isEmpty(); 90 } 91 92 98 public boolean hasPropertyErrors() { 99 return errors.hasPropertyErrors(); 100 } 101 102 110 public boolean hasPropertyErrors(String propertyName) { 111 return errors.hasPropertyErrors(propertyName); 112 } 113 114 124 public List getAllErrors() { 125 return errors.getAllErrors(); 126 } 127 128 136 public List getBasicErrors() { 137 return errors.getBasicErrors(); 138 } 139 140 149 public List getPropertyErrors() { 150 return errors.getPropertyErrors(); 151 } 152 153 161 public List getPropertyErrors(String property) { 162 return errors.getPropertyErrors(property); 163 } 164 165 171 public boolean isValid() { 172 return valid; 173 } 174 175 181 public void setValid(boolean valid) { 182 this.valid = valid; 183 } 184 185 188 public void clear() { 189 errors.clear(); 190 } 191 }
| Popular Tags
|