1 17 package servletunit.struts.tests; 18 19 import org.apache.struts.action.*; 20 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 24 public class ComplexFormAction extends Action { 25 26 32 public ActionForward execute(ActionMapping mapping, 33 ActionForm form, 34 HttpServletRequest request, 35 HttpServletResponse response) { 36 37 ComplexForm complexForm = (ComplexForm) form; 38 39 String username = complexForm.getUsername(); 40 String password = complexForm.getPassword(); 41 42 ActionErrors errors = new ActionErrors(); 43 44 if ((!username.equals("deryl")) || (!password.equals("radar")) || (complexForm.getComplexObject() == null)) 45 errors.add("password",new ActionMessage("error.password.mismatch")); 46 47 if (!errors.isEmpty()) { 48 saveErrors(request,errors); 49 return mapping.findForward("login"); 50 } 51 52 return mapping.findForward("success"); 53 } 54 55 } 56 | Popular Tags |