Uploaded image for project: 'Blossom'
  1. Blossom
  2. BLOSSOM-104

Support for inheriting areas from super class

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Fixed
    • Neutral
    • 2.0.5, 3.0.2
    • None
    • None
    • None

    Description

      Its common that many templates in a project have the same set of areas and it would be very useful if you could define them only once. Taking advantage of the class hierarchy is one way of doing this, just like blossom dialogs inherits tabs from the superclass.

      For example:

      public abstract class Superclass {
      
      	@Controller
      	@Area("headerArea")
      	public static class HeaderArea {
      
      		@RequestMapping("/headerArea")
      		public String render() {
      			return "areas/headerArea";
      		}
      	}
      }
      
      @Controller
      @Template(...)
      public class InheritedClass extends Superclass {
      	//...
      }
      

      Limitations

      It is however not possible to extend a class and override a method annotated with @RequestMapping. This due to a limitation in Spring MVC which fails to see that the method in the parent is overridden.

      The resulting exception is:

      Caused by: java.lang.IllegalStateException: Cannot map handler 'mainTemplateWithFooter' to URL path [/mainTemplate]: There is already handler of type [class info.magnolia.blossom.sample.module.MainTemplate] mapped.
      	at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:294)
      	at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:266)
      	at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
      	at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
      	at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
      	at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
      	at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
      	at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:117)
      	at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:92)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:396)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1505)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
      	... 79 more
      

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                tmattsson Tobias Mattsson
                tmattsson Tobias Mattsson
                Votes:
                4 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: