KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xpetstore > web > struts > action > product > SearchAction


1 package xpetstore.web.struts.action.product;
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.services.petstore.ejb.Petstore;
13
14 import xpetstore.web.struts.action.BaseAction;
15
16
17 /**
18  * @author Herve Tchepannou
19  *
20  * @struts.action
21  * name="searchForm"
22  * path="/search"
23  * scope="request"
24  * validate="false"
25  *
26  * @struts.action-forward
27  * name="success"
28  * path="search.jsp"
29  */

30 public class SearchAction
31     extends BaseAction
32 {
33     //~ Methods ----------------------------------------------------------------
34

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

38     protected ActionForward doExecute( ActionMapping mapping,
39                                        ActionForm form,
40                                        HttpServletRequest JavaDoc request,
41                                        HttpServletResponse JavaDoc response )
42         throws Exception JavaDoc
43     {
44         SearchForm frm = ( SearchForm ) form;
45         String JavaDoc keyword = frm.getKeyword( );
46         Petstore petstore = getPetstore( );
47
48         Collection JavaDoc products = petstore.searchProducts( keyword, 0, Integer.MAX_VALUE ).getList( );
49         frm.setProductValues( products );
50
51         return mapping.findForward( SUCCESS );
52     }
53 }
54
Popular Tags