[MGNLUI-2736] Actionbar add component fails for an optional area within a page Created: 10/Mar/14  Updated: 09/Mar/21  Resolved: 09/Mar/21

Status: Closed
Project: Magnolia UI
Component/s: pages app
Affects Version/s: 5.2.1, 5.2.2
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Peter Phillips Assignee: Unassigned
Resolution: Obsolete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File AddOptionalComponent.patch    
Template:
Patch included:
Yes
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

 Description   

The STK Section page template has an 'Opener' optional area. Selecting the area and then clicking 'Add component' on the action bar fails with the following error in the log:

2014-03-07 16:12:22,763 ERROR info.magnolia.pages.app.editor.PagesEditorSubApp  : An error occurred while executing action [addComponent]
javax.jcr.PathNotFoundException: /home/section/bnbmn/opener
    at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:552)
    at org.apache.jackrabbit.core.session.SessionItemOperation$4.perform(SessionItemOperation.java:97)
    at org.apache.jackrabbit.core.session.SessionItemOperation$4.perform(SessionItemOperation.java:93)
    at org.apache.jackrabbit.core.session.SessionItemOperation.perform(SessionItemOperation.java:187)
    at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216)
    at org.apache.jackrabbit.core.SessionImpl.perform(SessionImpl.java:361)
    at org.apache.jackrabbit.core.SessionImpl.getItem(SessionImpl.java:786)
    at info.magnolia.jcr.wrapper.DelegateSessionWrapper.getItem(DelegateSessionWrapper.java:154)
    at info.magnolia.jcr.wrapper.DelegateSessionWrapper.getItem(DelegateSessionWrapper.java:154)
    at info.magnolia.jcr.decoration.ContentDecoratorSessionWrapper.getItem(ContentDecoratorSessionWrapper.java:86)
    at info.magnolia.jcr.wrapper.DelegateSessionWrapper.getItem(DelegateSessionWrapper.java:154)
    at info.magnolia.jcr.wrapper.DelegateSessionWrapper.getItem(DelegateSessionWrapper.java:154)
    at info.magnolia.jcr.decoration.ContentDecoratorSessionWrapper.getItem(ContentDecoratorSessionWrapper.java:86)
    at info.magnolia.pages.app.editor.PagesEditorSubApp.prepareAndExecutePagesEditorAction(PagesEditorSubApp.java:390)
    at info.magnolia.pages.app.editor.PagesEditorSubApp.onActionbarItemClicked(PagesEditorSubApp.java:383)
    at info.magnolia.ui.actionbar.ActionbarPresenter.onActionbarItemClicked(ActionbarPresenter.java:183)
    at info.magnolia.ui.vaadin.actionbar.Actionbar$1.onActionTriggered(Actionbar.java:70)
    ...

Steps to reproduce:

  1. Create a page from the STK 'Section' template.
  2. Edit the page and select the 'OPENER [OPTIONAL]' area.
  3. Click the 'Add component' link in the actionbar.

Looking at the code (PagesEditorSubApp.java:390) it looks like it is expecting the area to exist before then trying to create the new component. Indeed if, instead of the last step, the link on the right of the opener area is clicked then a new opener area is added. This then shows a 'NEW OPENER COMPONENT' underneath the area and then clicking on the 'Add component' link in the actionbar then succeeds.

I have attached a patch (against master) which fixes the issue, but dubious that this is the best way to do it, since it checks to see if the node doesn't exist and if the user has clicked addComponent on an area and then adds the area. Not sure if it better either to automatically add the optional areas on page create, or alternatively provide the user with a 'Add area' link on the action bar first.



 Comments   
Comment by Peter Phillips [ 10/Mar/14 ]

I should have mentioned that I have successfully reproduced this issue by deploying the magnolia-empty-webapp (5.2.2) with magnolia-module-standard-templating-kit (2.7.2) and then following the steps above.

Generated at Mon Feb 12 08:59:38 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.