KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > web > struts > action > category > CategoryAction


1 package xpetstore.web.struts.action.category;
2
3 import java.util.Collection JavaDoc;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7
8 import org.apache.struts.action.ActionForm;
9 import org.apache.struts.action.ActionForward;
10 import org.apache.struts.action.ActionMapping;
11
12 import xpetstore.domain.catalog.ejb.Category;
13
14 import xpetstore.services.petstore.ejb.Petstore;
15
16 import xpetstore.web.struts.action.BaseAction;
17
18
19 /**
20  * @author <a HREF="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
21  *
22  * @struts.action
23  * name="categoryForm"
24  * path="/category"
25  * scope="request"
26  * validate="false"
27  *
28  * @struts.action-forward
29  * name="success"
30  * path="category.jsp"
31  */

32 public class CategoryAction
33     extends BaseAction
34 {
35     //~ Methods ----------------------------------------------------------------
36

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

40     protected ActionForward doExecute( ActionMapping mapping,
41                                        ActionForm form,
42                                        HttpServletRequest JavaDoc request,
43                                        HttpServletResponse JavaDoc response )
44         throws Exception JavaDoc
45     {
46         CategoryForm frm = ( CategoryForm ) form;
47         String JavaDoc categoryId = frm.getCategoryId( );
48         Petstore petstore = getPetstore( );
49
50         /* Category*/
51         Category category = petstore.getCategory( categoryId );
52         frm.setCategory( category );
53
54         /* Items */
55         Collection JavaDoc products = petstore.getProducts( categoryId, 0, Integer.MAX_VALUE ).getList( );
56         frm.setProducts( products );
57
58         return mapping.findForward( SUCCESS );
59     }
60 }
61
Popular Tags