Re: Multi-field sort ??

Sébastien Landeau <[email protected]>
Newsgroups gmane.comp.cms.jahia.template
Message-ID <[email protected]>
With this solution, you walk through the whole containerList and load all
keys and sort in memory.
How do you interact with the pagination mechanism ?
What about a large amount of data ?

Regards...

2005/9/29, Philippe Vollenweider <[email protected]>:
>
> Hello,
>
> You can do it manually using your own key. The idea would be
> something like this:
>
> ArrayList keys = new ArrayList();
> Hashtable keyToContainer = new Hashtable();
>
> JahiaContainerList containerList =
> jData.containers().getContainerList( "containerList" );
> Enumeration enumeration = containerList.getContainers();
> while (enumeration.hasMoreElements()) {
> JahiaContainer container = (JahiaContainer) enumeration.nextElement();
> String field1 = container.getFieldValue("field1","", false ,
> jData.params());
> String field2 = container.getFieldValue("field2","", false ,
> jData.params());
> String field3 = container.getFieldValue("field3","", false ,
> jData.params());
> String key = field1 + field2 + field3 + "_" + myContainer.getID();
> keyToContainer.put(myKey,myContainer);
> }
>
> Collections.sort(keys);
>
> //Collections.sort(keys,new Comparator() {
> // public int compare(Object o1, Object o2) {
> // String str1 = (String) o1;
> // String str2 = (String) o2;
> // return str2.compareTo(str1);
> // }
> //});
>
>
> for (int i = 0; i < keys.size(); i++) {
> String key = (String) keys.get(i);
> JahiaContainer container = keyToContainer(key);
> //...
> }
>
> Cheers,
>
> Philippe
>
> At 29.09.2005 10:38, you wrote:
>
> >Hi !
> >
> >I would like to know how to build multi-field sort (not a filter, a
> >SORT) on a containerList.
> >For example it's a need for sorting news by date, title and author (as
> >AND inclusive clause).
> >
> >The template directoryPeople seems to change the sorter each times you
> >do a selection in a combo box, so this is not a AND inlusive clause...
> >Any advice ?
> >
> >Thank's for your help...
>
> -------=[ pvollenweider at jahia dot com ]=---------
> Jahia : A collaborative source CMS and Portal Server
> www.jahia.org <http://www.jahia.org> Community and product web site
> www.jahia.com <http://www.jahia.com> Commercial services company
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.