loading table of contents...

Content Application Developer Manual / Version 2310

Table Of Contents Best Practices

  • When handler code isn't trivial, then this code should be considered to be moved to a separate service class. This makes the business code both better to test and reusable.

    This is a simple example:

    public ModelAndView handle(
                        @PathVariable("id") Integer id,
                        @PathVariable("command") String command) {
      Object result = getService()
                      .performComplexComputation(id, command);
      return HandlerHelper.createModel(result);
  • It's possible to use Spring's mechanism for an annotation based automatic instantiation and autowiring of handlers and other beans. This requires the bean classes to be annotated with @Controller, @Service, @Inject etc. as well as using a <context:component-scan> declaration.

    In contrast to this approach, CoreMedia suggests using the XML based way for defining and wiring beans. The reason is that in larger projects, using autowired beans may prove difficult to handle, especially when using external extensions.

    When declaring beans in XML, a developer exerts much more direct control over the application context.

  • Several handler methods may exist in the same class for the same URI path if they handle different request methods (such as GET or POST)

  • The best practice for handling POST requests can be found here Section, “Handling POST requests”
  • The best practice for handling redirects can be found here Section, “Handling redirects”

Search Results

Table Of Contents

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.