hi,

I'm trying to add a custom comparator to a 'related' tag. I know how to do this for a simple 'listnodes' tag:

implement a comparator:
<%!
// sorts suitcases
// 1 2 3 12 23 88 xx1 xx12 xx3 xx9
// so more than 9 'xx' suitcases will still be a problem
static public class MyComparator2 implements java.util.Comparator {
  public int compare(Object node1,Object node2) {
    String no1 = ((Node)node1).getStringValue("no");
    String no2 = ((Node)node2).getStringValue("no");
    if ( no1.length() < no2.length() ) {
      return -1;
    } else {
      return no1.compareTo(no2);
} } }
%>

and use it like this:

> <mm:listnodes type="suitcases" comparator="MyComparator2">

But how would I implement a comparator that works in a case like the following:

> <mm:related path="urls,suitcases" comparator="MyComparator3">

So this one has 2 builder types to list.
When I print the class of the node that gets passed to the comparator it looks like this:
 class org.mmbase.bridge.implementation.BasicNodeNODE
It seeems to contain info about both urls and suitcases, and if I specify fields="suitcases.no" in the related tag and I print the node it shows like this:

> prefix='',suitcases.no=1:'17',users0.number=9:'14436',urls.number=9:'14940',suitcases.number=9:'14488'

however, I cannot get the 'no' field by doing:

> String no1 = ((Node)node1).getStringValue("suitcase.no");

I hope someone knows what I missed/misunderstood.

cheers,

  Simon Groenewolt


_______________________________________________
Developers mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/developers

Reply via email to