1 27 package olstore.action; 28 29 30 import javax.servlet.http.HttpServletRequest; 31 import javax.servlet.http.HttpServletResponse; 32 33 import olstore.dto.AddressValue; 34 import olstore.dto.UserValue; 35 import olstore.form.DemoDynaBaseForm; 36 import olstore.framework.EJBHomeFactory; 37 38 import org.apache.commons.beanutils.BeanUtils; 39 import org.apache.struts.action.ActionError; 40 import org.apache.struts.action.ActionErrors; 41 import org.apache.struts.action.ActionForm; 42 import org.apache.struts.action.ActionForward; 43 import org.apache.struts.action.ActionMapping; 44 import org.apache.struts.action.ActionMessage; 45 import org.apache.struts.action.ActionMessages; 46 47 import olstore.session.helper.UserHelperLocal; 48 import olstore.session.helper.UserHelperLocalHome; 49 50 51 public class UserUpdateAction extends DemoBaseAction { 52 53 56 public ActionForward execute ( ActionMapping mapping, 57 ActionForm form, 58 HttpServletRequest request, 59 HttpServletResponse response 60 ) throws Exception { 61 62 try { 63 64 DemoDynaBaseForm modUserForm=(DemoDynaBaseForm) form; 65 UserValue userValue=new UserValue (); 66 AddressValue addressValue=new AddressValue(); 67 68 BeanUtils.copyProperties (addressValue, modUserForm); 70 BeanUtils.copyProperties (userValue, modUserForm); 71 72 String username=request.getRemoteUser(); 73 EJBHomeFactory factory=EJBHomeFactory.getInstance (); 74 UserHelperLocalHome userHelperHome=(UserHelperLocalHome) factory.getLocalHome (EJBHomeFactory.USER_HELPER); 75 UserHelperLocal userHelper=userHelperHome.create(); 76 77 userHelper.SaveUser (userValue, addressValue, username); 79 80 modUserForm.set ("submitType","new"); 82 83 UserModAction modAction=new UserModAction(); 85 modAction.loadUser(mapping, form, request, response); 86 87 ActionMessages messages = new ActionMessages(); 89 ActionMessage msg = new ActionMessage("user.save.success", username); 90 messages.add("success", msg); 91 saveMessages(request, messages); 92 93 return (new ActionForward(mapping.getInput())); 95 96 } catch ( Exception e ) { 97 ActionErrors errors = new ActionErrors(); 99 errors.add("error", new ActionError("errors.type.save", e.getMessage() )); 100 saveErrors(request, errors); 101 return (new ActionForward(mapping.getInput())); 103 } 104 105 } 106 } 107 | Popular Tags |