[MAGNOLIA-2885] editBar: if a non-existing singleton paragraph is edited, the newly created paragraph will be placed as a sibling of the page Created: 08/Oct/09  Updated: 23/Jan/13  Resolved: 12/Oct/09

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 4.1.1
Fix Version/s: 4.1.2, 4.2

Type: Bug Priority: Major
Reporter: Philipp Bärfuss Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File pastedGraphic.tiff    
Issue Links:
Cloners
clones MAGNOLIA-2740 Tag EDITBAR creates paragraph node on... Closed
clones MAGNOLIA-2741 Different behavior of uuidLink Contro... Closed
clones MAGNOLIA-2811 contentNodeName parameter of editBar ... 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   

Quote from a mail written by Giancarlo

If I use the "editBar" to do a "Singleton Paragraph" it does not work, since the contentNodeName is added as a sibling of the web page, and not as a paragraph (or paragraph list/paragraph).

As an example:
<cms:editBar contentNodeName="titleTextParagraph"
paragraph="titleText"/>
<cms:includeTemplate contentNodeName="titleTextParagraph"/>

I created the web page "myFirstDialogParagraph" and you see that the paragraph is now a sibling.

see



 Comments   
Comment by Philipp Bärfuss [ 08/Oct/09 ]

And the following fix has been proposed:

Take a look at the following snippet in the "doEndTag()" method

            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 it the variable "path" represents the paragraph node or the web page, the script will never get to the "else" statement.

Just adding above line solved the problem. Maybe you could fix the "editBar" tag code.

Comment by Zdenek Skodik [ 12/Oct/09 ]

looks like related to MAGNOLIA-2811 which was fixed with
-

 if(StringUtils.isNotEmpty(this.nodeName)){
                    try {
                        if (localContentNode.hasContent(this.nodeName)) {
                            localContentNode = localContentNode.getContent(this.nodeName);
                        } else {
                            localContentNode = null;
                        }
                    } catch (Exception e) {
                        // TODO: handle exception
                    }
Comment by Zdenek Skodik [ 12/Oct/09 ]


resolved at MAGNOLIA-2811.

Comment by Boris Kraft [ 19/Oct/09 ]

catch (Exception e)

{ // TODO: handle exception }

Don't swallow exceptions. Ever.
http://www.javalobby.org/java/forums/t91338.html

Comment by Jan Haderka [ 19/Oct/09 ]

Actually he doesn't Look at the last revision of the above mentioned code - rev28285

} catch (Exception e) {
       log.warn(e.getMessage(), e);
}
Generated at Mon Feb 12 03:41:04 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.