cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with sortElements

Former Member
0 Kudos

Hi .

I use the sortElements

Code :

<b>DefaultUnitsComparator comp;

comp = new DefaultUnitsComparator("ID");

wdContext.nodeUnitsDets().sortElements(comp);</b>

The compare method i implemented OK .

But....

I get an exception "java.lang.ArrayIndexOutOfBoundsException: 7 "

Why?( the Node is in size 7 )

Thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi, you've got a problem with your class DefaultUnitsComparator, could you paste the code here so i can help you?

Former Member
0 Kudos

Hi ,

<b>The code :</b>

<b>public</b> class DefaultUnitsComparator implements Comparator

{

String attribute;

<b>public</b> DefaultUnitsComparator(String attrib)

{

this.attribute = attrib;

}

<b>public</b> int compare(Object o1, Object o2)

{

try{

IWDNodeElement units1 = (IWDNodeElement) o1;

IWDNodeElement units2 = (IWDNodeElement) o2;

return units1.getAttributeAsText(attribute).

compareTo(units2.getAttributeAsText(attribute));

}

catch (Exception e)

{}

//arbitrary order

return 1;

}

Thanks,Faniel

Former Member
0 Kudos

Hi faniel,

If the array is in size 7, shouldn't the index be between 0 and 6 ? If so, index 7 will be out of bounds.

Nuno Santos

Former Member
0 Kudos

HI,

It implemented like the example...

The error happens on the sortelemnts....

java.lang.ArrayIndexOutOfBoundsException: 7

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.reorder(Node.java:2204)

at com.sap.tc.webdynpro.progmodel.context.Node.onListChange(Node.java:1521)

at com.sap.tc.webdynpro.progmodel.context.Node.access$1100(Node.java:85)

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.fireListEvent(Node.java:1920)

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.reorder(Node.java:2207)

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.rearrange(Node.java:2096)

at com.sap.tc.webdynpro.progmodel.context.Node$MappedElementList.rearrange(Node.java:2406)

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.sortElements(Node.java:2092)

<b>at com.sap.tc.webdynpro.progmodel.context.Node.sortElements</b>(Node.java:719)

Former Member
0 Kudos

Sorry, wrong thread.

Message was edited by:

Satyajit Chakraborty

Former Member
0 Kudos

Check this https://forums.sdn.sap.com/click.jspa?searchID=411422&messageID=246334

Where you are getting the exception ??

Regards,Anilkumar