org.compass.spring.web.mvc
Class CompassSearchController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by org.springframework.web.servlet.mvc.BaseCommandController
                      extended by org.springframework.web.servlet.mvc.AbstractCommandController
                          extended by org.compass.spring.web.mvc.AbstractCompassCommandController
                              extended by org.compass.spring.web.mvc.CompassSearchController
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller

public class CompassSearchController
extends AbstractCompassCommandController

A general Spring's MVC Controller that perform the search operation of Compass.

Will perform the search operation on the Compass instance using the query supplied by the CompassSearchCommand.

Pagination can be enabled by setting the pageSize property on the controller, as well as providing the page number property on the CompassSearchCommand.

The controller has two views to be set, the searchView, which is the view that holds the screen which the user will initiate the search operation, and the searchResultsView, which will show the results of the search operation (they can be the same page).

The results of the search operation will be saved under the searchResultsName, which defaults to "searchResults".

In order to extend and execute additional operations during the search process CompassSearchHelper should be extended and set using setSearchHelper(org.compass.core.support.search.CompassSearchHelper).

Author:
kimchy

Field Summary
 
Fields inherited from class org.springframework.web.servlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
CompassSearchController()
           
 
Method Summary
 void afterPropertiesSet()
           
 Integer getPageSize()
          Sets the page size for the pagination of the results.
 String getSearchResultsName()
          Returns the name of the results that the CompassSearchResults will be saved under.
 String getSearchResultsView()
          Returns the view which will show the results of the search operation.
 String getSearchView()
          Returns the view that holds the screen which the user will initiate the search operation.
protected  org.springframework.web.servlet.ModelAndView handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object command, org.springframework.validation.BindException errors)
           
 void setPageSize(Integer pageSize)
          Returns the page size for the pagination of the results.
 void setSearchHelper(CompassSearchHelper searchHelper)
          The search helper is used to execute teh actual search.
 void setSearchResultsName(String searchResultsName)
          Sets the name of the results that the CompassSearchResults will be saved under.
 void setSearchResultsView(String resultsView)
          Sets the view which will show the results of the search operation.
 void setSearchView(String searchView)
          Sets the view that holds the screen which the user will initiate the search operation.
 
Methods inherited from class org.compass.spring.web.mvc.AbstractCompassCommandController
getCompass, getCompassTemplate, setCompass
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractCommandController
handleRequestInternal
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommand, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, getWebBindingInitializer, initApplicationContext, initBinder, isValidateOnBinding, onBind, onBind, onBindAndValidate, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, setWebBindingInitializer, suppressBinding, suppressValidation, suppressValidation, suppressValidation, useDirectFieldAccess
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompassSearchController

public CompassSearchController()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class AbstractCompassCommandController
Throws:
Exception

handle

protected org.springframework.web.servlet.ModelAndView handle(javax.servlet.http.HttpServletRequest request,
                                                              javax.servlet.http.HttpServletResponse response,
                                                              Object command,
                                                              org.springframework.validation.BindException errors)
                                                       throws Exception
Specified by:
handle in class org.springframework.web.servlet.mvc.AbstractCommandController
Throws:
Exception

getSearchView

public String getSearchView()
Returns the view that holds the screen which the user will initiate the search operation.


setSearchView

public void setSearchView(String searchView)
Sets the view that holds the screen which the user will initiate the search operation.


getSearchResultsName

public String getSearchResultsName()
Returns the name of the results that the CompassSearchResults will be saved under. Defaults to "searchResults".


setSearchResultsName

public void setSearchResultsName(String searchResultsName)
Sets the name of the results that the CompassSearchResults will be saved under. Defaults to "searchResults".


getSearchResultsView

public String getSearchResultsView()
Returns the view which will show the results of the search operation.


setSearchResultsView

public void setSearchResultsView(String resultsView)
Sets the view which will show the results of the search operation.


getPageSize

public Integer getPageSize()
Sets the page size for the pagination of the results. If not set, not pagination will be used.


setPageSize

public void setPageSize(Integer pageSize)
Returns the page size for the pagination of the results. If not set, not pagination will be used.

Parameters:
pageSize - The page size when using paginated results

setSearchHelper

public void setSearchHelper(CompassSearchHelper searchHelper)

The search helper is used to execute teh actual search. By default (if not set) the search controller will create a new search helper. If provided, the search controller will use it to perform the search.

Mainly used to extend the search helper and execute additional operation within specific calbacks the search helper exposes.

Parameters:
searchHelper - A specific search helper to use


Copyright (c) 2004-2009 The Compass Project.