[MAGNOLIA-5040] Inheritance: nested areas cannot be inherited Created: 17/May/13  Updated: 17/May/13  Resolved: 17/May/13

Status: Closed
Project: Magnolia
Component/s: templating
Affects Version/s: 4.5.8
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Vivian Steller Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: area, inheritance, nested
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2013-05-17 at 10.56.30.png    
Issue Links:
duplicate
duplicates MAGNOLIA-4916 Add possibility to allow multiple wra... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Magnolia allows to nest areas within areas, since AreaDefinition extends TemplateDefinition. Regular rendering of these nested areas works just fine using [@cms.area/] within the template script of the surrounding area.

However, when trying to configure inheritance for such nested areas (see attached screenshot), Magnolia throws an exception during rendering:

...
[INFO] [talledLocalContainer] Caused by: freemarker.template.TemplateException: info.magnolia.rendering.engine.RenderException: Can't render area node /de/unternehmen/footer/footerLinks with name footerLinks
[INFO] [talledLocalContainer] 	at info.magnolia.templating.freemarker.AbstractDirective.execute(AbstractDirective.java:101)
[INFO] [talledLocalContainer] 	at freemarker.core.Environment.visit(Environment.java:274)
[INFO] [talledLocalContainer] 	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
[INFO] [talledLocalContainer] 	at freemarker.core.Environment.visit(Environment.java:221)
[INFO] [talledLocalContainer] 	at freemarker.core.MixedContent.accept(MixedContent.java:92)
[INFO] [talledLocalContainer] 	at freemarker.core.Environment.visit(Environment.java:221)
[INFO] [talledLocalContainer] 	at freemarker.core.Environment.process(Environment.java:199)
[INFO] [talledLocalContainer] 	at freemarker.template.Template.process(Template.java:237)
[INFO] [talledLocalContainer] 	at info.magnolia.freemarker.FreemarkerHelper.render(FreemarkerHelper.java:155)
[INFO] [talledLocalContainer] 	at info.magnolia.rendering.renderer.FreemarkerRenderer.onRender(FreemarkerRenderer.java:85)
[INFO] [talledLocalContainer] 	... 127 more
[INFO] [talledLocalContainer] Caused by: info.magnolia.rendering.engine.RenderException: Can't render area node /de/unternehmen/footer/footerLinks with name footerLinks
[INFO] [talledLocalContainer] 	at info.magnolia.templating.elements.AreaElement.end(AreaElement.java:325)
[INFO] [talledLocalContainer] 	at info.magnolia.templating.freemarker.AbstractDirective.execute(AbstractDirective.java:98)
[INFO] [talledLocalContainer] 	... 136 more
[INFO] [talledLocalContainer] Caused by: java.lang.IllegalArgumentException: node /de/footer/footerLinks/0 is already wrapped by info.magnolia.jcr.inheritance.InheritanceContentDecorator$OtherNodeInheritanceNodeWrapper and double wrapping is not supported.
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.setWrappedNode(DelegateNodeWrapper.java:96)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.<init>(DelegateNodeWrapper.java:87)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.decoration.ContentDecoratorNodeWrapper.<init>(ContentDecoratorNodeWrapper.java:71)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.inheritance.InheritanceContentDecorator$OtherNodeInheritanceNodeWrapper.<init>(InheritanceContentDecorator.java:225)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.inheritance.InheritanceContentDecorator.wrapNode(InheritanceContentDecorator.java:101)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.decoration.ContentDecoratorNodeIterator.wrapNode(ContentDecoratorNodeIterator.java:71)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.decoration.ContentDecoratorNodeIterator.nextNode(ContentDecoratorNodeIterator.java:62)
[INFO] [talledLocalContainer] 	at org.apache.jackrabbit.commons.iterator.FilteringNodeIterator.seekNext(FilteringNodeIterator.java:113)
[INFO] [talledLocalContainer] 	at org.apache.jackrabbit.commons.iterator.FilteringNodeIterator.<init>(FilteringNodeIterator.java:42)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.util.NodeUtil.getNodes(NodeUtil.java:604)
[INFO] [talledLocalContainer] 	at info.magnolia.jcr.util.NodeUtil.getNodes(NodeUtil.java:612)
[INFO] [talledLocalContainer] 	at info.magnolia.templating.elements.AreaElement.end(AreaElement.java:258)
[INFO] [talledLocalContainer] 	... 137 more

The issue is that Magnolia tries to double-wrap the inherited nodes.

One can work-around this issue by modifying the freemarker/model code:

[@cms.area name="footerLinks" content=model.unwrap(content.footerLinks)/]

model.unwrap simply does:

    public ContentMap unwrap(ContentMap wrappedContent) throws RepositoryException {
        return new ContentMap(NodeUtil.unwrap(wrappedContent.getJCRNode()));
    }

A cleaner solution/the fix should however, not simply unwrap the node but rather should not wrap the node again. Hence, info.magnolia.jcr.inheritance.InheritanceContentDecorator.wrapNode(Node) should check whether the node is already wrapped.



 Comments   
Comment by Roman Kovařík [ 17/May/13 ]

Hello Vivian,
it's known issue MAGNOLIA-4916, which is already fixed and will be part of Magnolia 4.5.9
InheritanceContentDecorator has to allow multiple wrapping and unwrapping may not be needed.

Comment by Vivian Steller [ 17/May/13 ]

Thanks, Roman, for the prompt response - these are great news

Generated at Mon Feb 12 04:01:24 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.