You need to sign in to do that
Don't have an account?
SFDC-NOOB
Why do I get method does not exist or incorrect signature error using comparable interface?
I am attempting to sort a list based on user clicking columns on visualforce page. Seems like the comparable interface is the best way to do this.
I can sort using static variables but it's messy. I would like to have dynamic variable to compare the list elements; however, I am receiving an error. Any help is greatly appreciated.
public class loadsort implements Comparable
{
public parseUtility.load load {get; set;}
public loadsort(parseutility.load ld)
{
load = ld;
}
public Integer compareTo(Object VLoad)
{
loadsort LoadToComp = (loadsort)VLoad;
if(Load.get(comparefield) > Loadtocomp.load.get(comparefield))
return SortOrder.equals('asc') ? 1 : 0;
else
return sortOrder.equals('asc') ? 0 : 1;
}
}
This is the error:::::: Method does not exist or incorrect signature: [ParseUtility.load].get(String)
I can sort using static variables but it's messy. I would like to have dynamic variable to compare the list elements; however, I am receiving an error. Any help is greatly appreciated.
public class loadsort implements Comparable
{
public parseUtility.load load {get; set;}
public loadsort(parseutility.load ld)
{
load = ld;
}
public Integer compareTo(Object VLoad)
{
loadsort LoadToComp = (loadsort)VLoad;
if(Load.get(comparefield) > Loadtocomp.load.get(comparefield))
return SortOrder.equals('asc') ? 1 : 0;
else
return sortOrder.equals('asc') ? 0 : 1;
}
}
This is the error:::::: Method does not exist or incorrect signature: [ParseUtility.load].get(String)
Something like following should work in that case
All Answers
My application makes a callout, the response is parsed into this class. Then the list is returned to a visualforce page.
The relevant part of the parse utility class is below. Thanks in advance!
public class ParseUtility{
public class load {
public string age { get; set; }
public string companyName { get; set; }
public string origincity { get; set; }
public string originstate { get; set; }
public string origindistance { get; set; }
public string destinationcity { get; set; }
public string destinationstate { get; set; }
public string destinationDistance { get; set; }
public string equipment { get; set; }
public string length { get; set; }
public string loadtype { get; set; }
public string miles { get; set; }
public string payment { get; set; }
public string pickupdate { get; set; }
public string pricePerGall { get; set; }
public string weight { get; set; }
}
}
Something like following should work in that case