Opus College – Techniques Spring Annotated Controllers
OpusCollege Spring 2.5 offers Annotations on several levels, a.o.: Transaction Management OSGi MVC Controllers: for Servlet MVC and Portlet MVC. Controllers implemented in this style do not have to extend specific base classes or implement specific interfaces.
OpusCollege Setting up the dispatcher for annotation support: will only be processed if a corresponding HandlerMapping (for type level annotations) and/or HandlerAdapter (for method level annotations) is present in the dispatcher. This is the case by default in both DispatcherServlet and DispatcherPortlet. See:..college.applicationContext.xml
OpusCollege Setting up the dispatcher for component scanning stereotype allows for autodetection, aligned with Spring 2.5's general support for detecting component classes in the classpath and auto-registering bean definitions for them. To enable autodetection of such annotated controllers, you have to add component scanning to your configuration. This is easily achieved by using the spring-context schema. See:..college.applicationContext.xml
OpusCollege Defining a controller – request mapping: Mapping requests typically the type-level annotation maps a specific request path (or path pattern) onto a form controller, with additional method-level annotations 'narrowing' the primary mapping for a specific HTTP method request method ("GET"/"POST") or specific HTTP request parameters. See: StudyEditController + StudyDeleteController
OpusCollege Defining a controller – advanced options: Session object (Servlet API): of type HttpSession. An argument of this type will enforce the presence of a corresponding session. As a consequence, such an argument will never be null. annotated parameters for access to specific Servlet request parameters. Parameter values will be converted to the declared method argument type. java.util.Map / org.springframework.ui.Model / org.springframework.ui.ModelMap for enriching the implicit model that will be exposed to the web view. See: StudyEditController
OpusCollege Defining a controller – advanced options: Command/form objects to bind parameters to: as bean properties or fields. In Opus: form object with at least the underlying domain object + custom organization and navigationSettings objects org.springframework.validation.Errors / org.springframework.validation.BindingResult validation results for a preceding command/form object (the immediate preceding argument). org.springframework.web.bind.support.SessionStatus status handle for marking form processing as complete (triggering the cleanup of session attributes that have been indicated by annotation at the handler type level). See: StudyEditController
OpusCollege Defining a controller – advanced options: Configuring a custom WebBindingInitializer: To externalize data binding initialization, you can provide a custom implementation of the WebBindingInitializer interface, which you then enable by supplying a custom bean configuration for an AnnotationMethodHandlerAdapter, thus overriding the default configuration. Used in Opus to define See:..college.applicationContext.xml See:..college.config.opusBindingInitializer
Questions ???