KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > web > struts > action > item > ItemAction


1 package xpetstore.web.struts.action.item;
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.catalog.ejb.Item;
11 import xpetstore.domain.catalog.ejb.Product;
12
13 import xpetstore.services.petstore.ejb.Petstore;
14
15 import xpetstore.web.struts.action.BaseAction;
16
17
18 /**
19  * @author <a HREF="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
20  *
21  * @struts.action
22  * name="itemForm"
23  * path="/item"
24  * scope="request"
25  * validate="false"
26  *
27  * @struts.action-forward
28  * name="success"
29  * path="/item.jsp"
30  */

31 public class ItemAction
32     extends BaseAction
33 {
34     //~ Methods ----------------------------------------------------------------
35

36     /**
37      * @see xpetstore.web.struts.action.BaseAction#doExecute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)
38      */

39     protected ActionForward doExecute( ActionMapping mapping,
40                                        ActionForm form,
41                                        HttpServletRequest JavaDoc request,
42                                        HttpServletResponse JavaDoc response )
43         throws Exception JavaDoc
44     {
45         ItemForm frm = ( ItemForm ) form;
46         String JavaDoc itemId = frm.getItemId( );
47         Petstore petstore = getPetstore( );
48
49         /* Item */
50         Item item = petstore.getItem( itemId );
51         frm.setItem( item );
52
53         /* Product */
54         Product product = petstore.getProductByItem( itemId );
55         frm.setProduct( product );
56
57         return mapping.findForward( SUCCESS );
58     }
59 }
60
Popular Tags