1 package xpetstore.web.struts.action.customer; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionForward; 8 import org.apache.struts.action.ActionMapping; 9 10 import xpetstore.domain.customer.ejb.Customer; 11 12 import xpetstore.services.petstore.exceptions.DuplicateAccountException; 13 import xpetstore.services.petstore.exceptions.DuplicateEmailException; 14 15 import xpetstore.web.struts.action.BaseAction; 16 17 18 36 public class CreateCustomerAction 37 extends BaseAction 38 { 39 41 44 protected ActionForward doExecute( ActionMapping mapping, 45 ActionForm form, 46 HttpServletRequest request, 47 HttpServletResponse response ) 48 throws Exception 49 { 50 CustomerForm frm = ( CustomerForm ) form; 51 Customer cust = frm.getCustomer( ); 52 53 try 54 { 55 getPetstore( ).createCustomer( cust ); 56 return mapping.findForward( SUCCESS ); 57 } 58 catch ( DuplicateAccountException da ) 59 { 60 request.setAttribute( MESSAGE_KEY, "duplicate_account" ); 61 62 return mapping.findForward( ERROR ); 63 } 64 catch ( DuplicateEmailException de ) 65 { 66 request.setAttribute( MESSAGE_KEY, "duplicate_email" ); 67 68 return mapping.findForward( ERROR ); 69 } 70 } 71 } 72 | Popular Tags |