MainOverviewWikiIssuesForumBuildFisheye

Chapter 30. Spring MVC Support

30.1. Introduction

Compass::Spring provides helper and support classes that build and integrate with Spring web MVC support. It has several base class controller helpers, as well as search and index controllers.

30.2. Support Classes

Two abstract command controllers are provided. The AbstractCompassCommandController is a general base class for Spring's MVC Command Controller that use Compass. The AbstractCompassGpsCommandController is a general base class for the Command Controller that use CompassGps.

30.3. Index Controller

CompassIndexController is a Spring Command Controller that can handle index() operations to perform on a CompassGps.

The controller command is CompassIndexCommand. The CompassIndexController command controller will perform the index() operation only if the doIndex parameter is set.

The controller has two views to be set. The indexView is the view that holds the screen which initiates the index operation, and the indexResultsView, which shows the results of the index operation.

The results of the index operation will be saved under the indexResultsName, which defaults to "indexResults". The results use the CompassIndexResults class.

30.4. Search Controller

CompassSearchController is a general Spring's MVC Controller that perform the search operation of Compass.

The Controller performs the search operation on the Compass instance using the query supplied by the CompassSearchCommand. The command holds the query that will be executed, as well as the page number (using the pagination feature).

If you wish to enable the pagination feature, you must set 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". The results use the CompassSearchResults class.

Note, that if using the SpringSyncTransactionFactory, the transactionManager must be set. Since when using the spring sync transaction setting, a spring managed transactions must be in progress already. The controller will start a transcation using the given transaction manager.