1 package com.inversoft.verge.mvc.config; 2 3 4 import java.util.Map ; 5 6 import com.inversoft.error.ErrorRegistry; 7 import com.inversoft.error.PropertyError; 8 import com.inversoft.verge.mvc.controller.Action; 9 import com.inversoft.verge.mvc.validator.Validator; 10 import com.inversoft.verge.util.WebBeanProperty; 11 12 13 26 public class OverrideValidator implements Validator { 27 28 private PropertyConfig config; 29 30 31 38 public OverrideValidator(PropertyConfig config) { 39 this.config = config; 40 } 41 42 43 51 public boolean validate(Map modelObjects, Action action) { 52 return true; 54 } 55 56 66 public void handleConversion(Object model, WebBeanProperty property, 67 Action action) { 68 69 Object [] params = null; 70 if (config.getParameters() != null) { 71 params = config.getParameters().values().toArray(); 72 } 73 74 PropertyError error = null; 76 if (config.getKey() != null) { 77 error = ErrorRegistry.getPropertyError(config.getBundleName(), 78 config.getKey(), null, property.getFullName(), null, params); 79 } else { 80 error = new PropertyError(property.getFullName(), config.getErrorMsg(), 81 params); 82 } 83 84 action.getRequestContext().addError(error); 85 } 86 } | Popular Tags |