[ 
http://jira.magnolia-cms.com/browse/MAGNOLIA-2885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=24389#action_24389
 ] 

Philipp Bärfuss commented on MAGNOLIA-2885:
-------------------------------------------

And the following fix has been proposed:

{quote}
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.
{quote}

> editBar: if a non-existing singleton paragraph is edited, the newly created 
> paragraph will be placed as a sibling of the page
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MAGNOLIA-2885
>                 URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-2885
>             Project: Magnolia
>          Issue Type: Bug
>          Components: taglibs
>    Affects Versions: 4.1.1
>            Reporter: Philipp Bärfuss
>            Assignee: Fabrizio Giustina
>         Attachments: pastedGraphic.tiff
>
>
> Quote from a mail written by Giancarlo
> {quote}
> 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.
> {quote}
> see !pastedGraphic.tiff!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to