Package com.m4f.web.bind.form

Examples of com.m4f.web.bind.form.SearchForm


  public String getSearchForm(
      @RequestParam(defaultValue = "", required = false) String q,
      @RequestParam(defaultValue = "hirubila-nonreglated-", required = false) String collection,
      @RequestParam(defaultValue = "1", required = false) Integer page,
      Model model, Locale locale) {
    SearchForm searchForm = new SearchForm();
    searchForm.setCollection(collection);
    try {
      if (q != null && !("").equals(q)) {
        StringTokenizer terms = new StringTokenizer(q.trim());
        SearchParamsImpl params = new SearchParamsImpl();
        params.addParam(PARAM.CLIENT, gsa_client);
        params.addParam(PARAM.SEARCH_URI, this.serviceLocator.getAppConfigurationService().
            getGlobalConfiguration().getSearchUri());
        params.addParam(PARAM.BASE_COLLECTION_NAME, collection);                       
        params.addParam(PARAM.LANG, locale.getLanguage());
        PageManager<ISearchResults> paginator = new PageManager<ISearchResults>();
        paginator.setStart((page - 1) * paginator.getOffset());
        params.addParam(PARAM.START, String.valueOf(paginator
            .getStart()));
        this.serviceLocator.getSearchEngine().search(terms, params);
        ISearchResults results = this.serviceLocator.getSearchEngine().getSearchResults();
        paginator.setCollection((Collection) results);
        try {
          paginator
              .setSize(Long.parseLong(results.getTotalResults()));
          model.addAttribute("paginator", paginator);
        } catch (Exception e) {
          paginator.setSize(0);
        }
      }
    } catch (Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
    }

    if (q != null && !("").equals(q)) {
      searchForm.setQuery(q);
      model.addAttribute("search", searchForm);
      return "search.results";
    } else {
      model.addAttribute("search", searchForm);
      return "search.form";
View Full Code Here


      List<Category> tags = this.serviceLocator.getCourseService().getCoursesTags(locale);
     
      model.addAttribute("provinces", provinces);
      model.addAttribute("regions", regions);
      model.addAttribute("tags", tags);
      model.addAttribute("search", new SearchForm());
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here

TOP

Related Classes of com.m4f.web.bind.form.SearchForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.