FileDocCategorySizeDatePackage
SearchPagesController.javaAPI DocExample2704Mon Mar 01 19:52:14 GMT 2004org.springframework.samples.jpetstore.web.spring

SearchPagesController

public class SearchPagesController extends Object implements org.springframework.web.servlet.mvc.Controller
author
Justin Gehtland
since
3.1.2004

Fields Summary
private org.springframework.samples.jpetstore.domain.logic.PetStoreFacade
petStore
Constructors Summary
Methods Summary
public org.springframework.web.servlet.ModelAndViewhandleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

		if (request.getParameter("search") != null) {
			String keyword = request.getParameter("keyword");
			if (keyword == null || keyword.length() == 0) {
				return new ModelAndView("Error", "message", "Please enter a keyword to search for, then press the search button.");
			}
			else {
                ConfigBean cfg = new ConfigBean();
                String indexpath = "";
                try
                {
                    indexpath = cfg.getCurIndexPath();
                }
                catch(Exception ex)
                {
                  return new ModelAndView("Error", "message", "Could not find current index path.");
                }

                QueryBean qb = new QueryBean("D:/@Tools/jakarta-tomcat-5.0.18/webapps/SiteSearch/WEB-INF/index.0", keyword, "contents");

                qb.execute();

                HashMap hits = new HashMap(qb.getResults().length);
                for(int i =0;i<qb.getResults().length;i++)
                {
                    hits.put("hits", qb.getResults());
                }
                return new ModelAndView("SearchProducts", hits);
				//return new ModelAndView("Error", "message", "QB Total: " + qb.getResults().length + " and hits: " + hits.size());

			}
		}
		else {
			String page = request.getParameter("page");
			PagedListHolder productList = (PagedListHolder) request.getSession().getAttribute("SearchProductsController_productList");
			if ("next".equals(page)) {
				productList.nextPage();
			}
			else if ("previous".equals(page)) {
				productList.previousPage();
			}
			return new ModelAndView("SearchProducts", "productList", productList);
		}
	
public voidsetPetStore(org.springframework.samples.jpetstore.domain.logic.PetStoreFacade petStore)

		this.petStore = petStore;