[MAGNOLIA-2740] Tag EDITBAR creates paragraph node on root level Created: 21/May/09  Updated: 23/Jan/13  Resolved: 08/Oct/09

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 4.0.1
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Giancarlo Berner Assignee: Fabrizio Giustina
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mg 4.1, Tomcat 6, Windows XP, FireFox


Issue Links:
Cloners
is cloned by MAGNOLIA-2885 editBar: if a non-existing singleton ... 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

 Description   

In an exercise we are doing a "Top Level" paragraph:
<%-- Draw the Edit Bar with the Edit button to show the Dialog --%>
<cms:editBar paragraph="exerciseTitle"
contentNodeName="exerciseTitle"
editLabel="Edit Exercise Title"
moveLabel=""
deleteLabel=""/>

<%-- Run the script defined in the paragraph
template property "templatePath" --%>
<cms:includeTemplate contentNodeName="exerciseTitle" />

In 3.6.5 and prior versions the tag created a paragraph node "exerciseTitle" (type 'ContentNode') as child of the current Web page (type 'Content').

But in 4.1 the paragraph node is placed on the root level.

  • Tried with sub pages, paragraph node still ends up on root level
  • Added attribute "contentNodeCollectionName", that paragraph list node is also created on root level


 Comments   
Comment by Giancarlo Berner [ 04/Oct/09 ]

When do you think will this be resolved?

Comment by Giancarlo Berner [ 05/Oct/09 ]

Jackson took a look at the editBar tag. We think there is an easy fix for now.

Take a look at the following snippet in the "doEndTag()" method, the two lines starting with "// Add the following line:

try {
BarEdit bar = new BarEdit();

Content localContentNode = Resource.getLocalContentNode();

if(StringUtils.isNotEmpty(this.nodeName)){
try

{ localContentNode = localContentNode.getContent(this.nodeName); }

catch (Exception e)

{ // TODO: handle exception // Add the following line: localContentNode = null; }

}

The reason why you want to "null-out" the localContentNode if the paragraph node is not found, is the following snippet:

bar.setNodeName(this.nodeName);

try {
String path;
if (localContentNode != null) {
path = localContentNode.getParent().getHandle();
if (StringUtils.isNotEmpty(this.nodeCollectionName) && path.endsWith("/" + this.nodeCollectionName))

{ path = StringUtils.removeEnd(path, "/" + this.nodeCollectionName); }

}
else

{ path = Resource.getCurrentActivePage().getHandle(); }

bar.setPath(path);
}
catch (Exception re)

{ bar.setPath(StringUtils.EMPTY); }

In the above snippet, the "localContentNode" is never set to "null". So either the variable "path" represents the paragraph node or the web page, but the script will never get to the "else" statement.
Of course you might also want to take a look at the deprecated methods

>>> Jackson, thanks for looking into this!

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