You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Kh...@fr.thalesgroup.com on 2005/07/26 09:37:20 UTC

problem on a sort

Hi all,

 

It seems that there is a problem on the class BasePortletSet from the package org.apache.jetspeed.portal.

Indeed, the algorithm of sort from the method sortPortletSet is not correct. 

Should it not be something like that:

 

synchronized (portlets)

        {

            Collections.sort(portlets, new PortletSetComparator());

                  

            this.dirty = false;   

        }

 

Where PortletSetComparator could be:

 

public class PortletSetComparator implements Comparator

{

    public int compare(Object p1, Object p2)

    {

        Portlet po1 = (Portlet) p1;

        Portlet po2 = (Portlet) p2;

        

        int pos1 = po1.getPortletConfig().getPosition();

        int pos2 = po2.getPortletConfig().getPosition();

        

        return pos1 - pos2;

    }

    

    public boolean equals(Object p1, Object p2)

    {

        Portlet po1 = (Portlet) p1;

        Portlet po2 = (Portlet) p2;

        

        int pos1 = po1.getPortletConfig().getPosition();

        int pos2 = po2.getPortletConfig().getPosition();

        

        return (pos1 == pos2);

    }

 

Thanks

 

Khanh