1 27 package olstore.action; 28 29 34 import javax.servlet.http.*; 35 38 import olstore.session.helper.TypeHelperLocal; 41 import olstore.session.helper.TypeHelperLocalHome; 42 46 import olstore.dto.TypeValue; 47 import olstore.form.CreateTypeForm; 48 import olstore.framework.EJBHomeFactory; 49 50 import org.apache.struts.action.*; 51 import org.apache.commons.beanutils.BeanUtils; 52 53 54 public class TypeSaveAction extends DemoBaseAction { 55 56 public ActionForward execute ( ActionMapping mapping, 57 ActionForm form, 58 HttpServletRequest request, 59 HttpServletResponse response 60 ) throws Exception { 61 62 try { 63 64 CreateTypeForm createForm = (CreateTypeForm)form; 65 TypeValue typeVal = new TypeValue(); 66 BeanUtils.copyProperties ( typeVal , createForm ); 67 68 EJBHomeFactory factory = EJBHomeFactory.getInstance(); 69 TypeHelperLocalHome typeHelperHome = (TypeHelperLocalHome) factory.getLocalHome ( EJBHomeFactory.TYPE_HELPER ); 70 TypeHelperLocal typeHelper = typeHelperHome.create(); 71 72 typeHelper.saveType ( typeVal ); 73 74 ActionMessages messages = new ActionMessages(); 75 ActionMessage msg = new ActionMessage("type.save.success", 76 typeVal.getName() ); 77 messages.add("success", msg); 78 saveMessages(request, messages); 79 80 return mapping.findForward ( "updateType" ); 81 } catch ( Exception e ) { 82 ActionErrors errors = new ActionErrors(); 84 errors.add("error", new ActionError("errors.type.save", e.getMessage() )); 85 saveErrors(request, errors); 86 return (new ActionForward(mapping.getInput())); 88 } 89 90 } 91 92 } 93 | Popular Tags |