KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > web > struts > action > customer > UpdateCustomerAction


1 package xpetstore.web.struts.action.customer;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import javax.servlet.http.HttpServletResponse JavaDoc;
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.DuplicateEmailException;
13
14 import xpetstore.web.struts.action.BaseAction;
15
16
17 /**
18  * @author <a HREF="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
19  *
20  * @struts.action
21  * name="customerForm"
22  * path="/updateCustomer"
23  * scope="request"
24  * validate="true"
25  * input="/myaccount.jsp"
26  *
27  * @struts.action-forward
28  * name="success"
29  * path="/index.jsp"
30  *
31  * @struts.action-forward
32  * name="error"
33  * path="/myaccount.jsp"
34  */

35 public class UpdateCustomerAction
36     extends BaseAction
37 {
38     //~ Methods ----------------------------------------------------------------
39

40     /**
41      * @see xpetstore.web.struts.action.BaseAction#doExecute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)
42      */

43     protected ActionForward doExecute( ActionMapping mapping,
44                                        ActionForm form,
45                                        HttpServletRequest JavaDoc request,
46                                        HttpServletResponse JavaDoc response )
47         throws Exception JavaDoc
48     {
49         CustomerForm frm = ( CustomerForm ) form;
50         Customer cust = frm.getCustomer( );
51
52         try
53         {
54             getPetstore( ).updateCustomer( cust );
55
56             initSession( cust, request );
57
58             return mapping.findForward( SUCCESS );
59         }
60         catch ( DuplicateEmailException de )
61         {
62             request.setAttribute( MESSAGE_KEY, "duplicate_email" );
63
64             return mapping.findForward( ERROR );
65         }
66     }
67 }
68
Popular Tags