Re: Multi-field sort ??

Philippe Vollenweider <[email protected]>
Newsgroups gmane.comp.cms.jahia.template
Message-ID <[email protected]>
Oops, I forgot to ad the key on the array list... add keys.add( key 
); near keyToContainer.put(myKey,myContainer);

Philippe.

At 29.09.2005 11:12, you wrote:
>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 Community and product web site
>www.jahia.com Commercial services company

-------=[ pvollenweider at jahia dot com ]=---------
Jahia : A collaborative source CMS and Portal Server
www.jahia.org Community and product web site
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.