CLONE -MultiSelect does not keep the order of its value items (NodeDatas)
-------------------------------------------------------------------------

                 Key: MAGNOLIA-4692
                 URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-4692
             Project: Magnolia
          Issue Type: Bug
      Security Level: Public
          Components: admininterface
    Affects Versions: 4.4.6
            Reporter: Will Scheidegger
            Assignee: Jaroslav Simak
             Fix For: 4.5.5


If you use the multiSelect control in a dialog to select three nodes A, B and 
C, Magnolia will correctly save something like

- myMultiValueNode
   -- 0: A
   -- 1: B
   -- 2: C

But when you open the dialog the next time, chances are that the order will not 
be correct anymore. You save again and the order will now also be messed up in 
the repository. I don't know exactly why this is happening, but it boils down 
to Content.getNodeDataCollection() not returning the nodes in the "proper" 
order.

However this is easily fixed: Simply sort the NodeDatas by name when retrieved 
from the Content object:


ArrayList<NodeData> nodeDatas = new 
ArrayList<NodeData>(this.getStorageNode().getContent(this.getName()).getNodeDataCollection());

Collections.sort(nodeDatas, new Comparator() {
    @Override
    public int compare(Object arg0, Object arg1) {
        return ((NodeData) arg0).getName().compareTo(((NodeData) 
arg1).getName());
    }
});
Iterator it = nodeDatas.iterator();
...

The attached patch does exactly this.

-- 
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/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to