1 27 package olstore.action; 28 29 import javax.servlet.http.HttpServletRequest; 30 import javax.servlet.http.HttpServletResponse; 31 32 import olstore.form.DemoDynaBaseForm; 33 34 import org.apache.struts.action.ActionError; 35 import org.apache.struts.action.ActionErrors; 36 import org.apache.struts.action.ActionForm; 37 import org.apache.struts.action.ActionForward; 38 import org.apache.struts.action.ActionMapping; 39 40 41 42 public class UserCreateAction extends DemoBaseAction { 43 44 48 49 public ActionForward execute ( ActionMapping mapping, 50 ActionForm form, 51 HttpServletRequest request, 52 HttpServletResponse response) throws Exception{ 53 54 try { 55 DemoDynaBaseForm createUserForm=(DemoDynaBaseForm) form; 56 String action = (String) createUserForm.get("submitType"); 57 if ( action.equals("new") ){ 58 return mapping.findForward ("CreateUser"); 59 } 60 else if (action.equals("Cancel")){ 61 return new ActionForward("/views/index.do", true); 62 } 63 else { 64 return mapping.findForward ("SaveUser"); 65 } 66 67 } 68 catch ( Exception e ) { 69 ActionErrors errors = new ActionErrors(); 71 errors.add("error", new ActionError("errors.item.load", e.getMessage() )); 72 saveErrors(request, errors); 73 return (new ActionForward(mapping.getInput())); 75 } 76 77 } 78 } 79 80 81 82 | Popular Tags |