Difference between
version 48
and
version 47:
| At line 30 changed 8 lines. |
| import org.appfuse.model.User; |
|
| import org.springframework.validation.Errors; |
| import org.springframework.validation.Validator; |
|
| public class UserValidator implements Validator { |
| public boolean supports(Class clazz) { |
| return clazz.equals(User.class); |
| protected ConfigurableApplicationContext createContext() throws Exception { |
| ConfigurableWebApplicationContext root = new XmlWebApplicationContext(); |
| MockServletContext sc = new MockServletContext(""); |
| root.setServletContext(sc); |
| root.setConfigLocations(new String[] {"web/WEB-INF/applicationContext.xml"}); |
| root.refresh(); |
| ConfigurableWebApplicationContext wac = new XmlWebApplicationContext(); |
| wac.setParent(root); |
| wac.setServletContext(sc); |
| wac.setNamespace("action-servlet"); |
| wac.setConfigLocations(new String[] {"web/WEB-INF/action-servlet.xml"}); |
| wac.refresh(); |
| return wac; |
| At line 40 changed 7 lines. |
| public void validate(Object obj, Errors errors) { |
| User user = (User) obj; |
|
| if ("".equals(user.getLastName())) { |
| errors.rejectValue("lastName", "errors.required", |
| new Object[] { "Last Name" }, "Value required."); |
| } |
| public void setUp() throws Exception { |
| ctx = createContext(); |
| At line 48 removed 1 line. |
| } |
Back to SandBox,
or to the Page History.
|