[BLOSSOM-104] Support for inheriting areas from super class Created: 31/Jan/13  Updated: 28/Aug/15  Resolved: 04/Apr/14

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.5, 3.0.2

Type: New Feature Priority: Neutral
Reporter: Tobias Mattsson Assignee: Tobias Mattsson
Resolution: Fixed Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
dependency
duplicate
is duplicated by BLOSSOM-145 Support for areas with class inheritance Closed
Template:
Acceptance criteria:
Empty
Date of First Response:

 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


 Comments   
Comment by Jan Haderka [ 06/Dec/14 ]

Bulk close of old resolved tickets.

Generated at Sun Feb 11 23:30:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.