cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Row Selection - Exception

Former Member
0 Kudos

Hi All,

I am getting the following exception in multiple row selection :-

java.lang.IndexOutOfBoundsException: Index: 2, Size: 2

at java.util.ArrayList.RangeCheck(ArrayList.java:507)

at java.util.ArrayList.get(ArrayList.java:324)

at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.getElement(Node.java:2034)

at com.sap.tc.webdynpro.progmodel.context.Node.isMultiSelected(Node.java:841)

at com.sap.tc.webdynpro.progmodel.context.Node.isMultiSelected(Node.java:839)

I have made the following settings :-

Cardinality : 0.n

Selection : 1.n

Selection Mode of Table : Multi

i am using value nodes in my Application.

Please suggest some solution

Thanks,

Nikhil

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

hi!

make sure "selectionmode" property is "multi" and also selection should be 0.. n.

and then In the controller program use the method "isMultiSelected" of the mapped Node to check whether the multiple lines are selected.

i am sending you the sample code to show the selected row indices

StringBuffer msg = new StringBuffer("Multi-selected rows:");

for (int i = 0; i < wdContext.nodeRows().size(); ++i)

{

if (wdContext.nodeRows().isMultiSelected(i))

{

msg.append(" ").append(i);

}

}

wdComponentAPI.getMessageManager().reportSuccess(msg.toString());

thanks

vishal

Former Member
0 Kudos

Hi,

Try this code

for(int i=0;i<nodesize();i++)

{

if(wdContext.node<<abc>>.isSelected(i)

{

wdContext.node<<abc()>>.removeElement(wdContext.nodeabc().getabcElementat(i));

}

}

Regards

Raghu

Former Member
0 Kudos

Hi,

if you have any condition checking the node size ,make sure that the proper node using .

Regards,

ramesh

Former Member
0 Kudos

Hi

go through this forums link it will help u

Regards

Ruturaj

Former Member
0 Kudos

Hi,

Check your For loop iterator code or else post your code.

it should be like this

for(int i=0;i<wdContext.nodeABC().size();i++)

Regards

Raghu

Former Member
0 Kudos

hi,

there may be some error in your code

like node.size()>=2

it must be node.size>2 not equal to

where 2 is the size of the node

where as the index starts from 0

jus correct ur code

ur settings of properties look alright

Regards,

Satya.

Former Member
0 Kudos

I am using the following code for deleting 1 or more rows in a table :-

for (int j = 0; j < tableSize; ++j)

{

if (wdContext.nodeCn_Table().getLeadSelection() == j

|| wdContext.nodeCn_Table).isMultiSelected(j))

{

entry =wdContext.currentCn_TableElement(); wdContext.nodeCn_Table().removeElement(entry);

}

}

Nikhil

Edited by: NIKHIL GULATI on Oct 6, 2008 8:58 AM

Former Member
0 Kudos

hi,

try similar implementation for ur requirement.

int nelems = wdContext.nodePeople().size();

int lead =wdContext.nodePeople().getLeadSelection();

// checking if the lead selection is valid

for(int i=nelems-1;i<nelems;--i){

if(wdContext.nodePeople().isMultiSelected(i)||lead==i){

// deleting the element

wdContext.nodePeople().removeElement(wdContext.nodePeople().getElementAt(i));

}

Regards,

Satya.

Former Member
0 Kudos

Hi,

problem in your code,

for (int j = 0; j < tableSize; ++j)

{

if (wdContext.nodeCn_Table().getLeadSelection() == j

|| wdContext.nodeCn_Table).isMultiSelected(j))

{

// entry =wdContext.currentCn_TableElement(); replace this with below one

entry = wdContext.nodeCn_Table().getCn_TableElementAt(j);

wdContext.nodeCn_Table().removeElement(entry);

}

}

Regards,

ramesh

Former Member
0 Kudos

Hi ,

for (int j = 0; j < tableSize; ++j)

{

if (wdContext.nodeCn_Table().getLeadSelection() == j

|| wdContext.nodeCn_Table).isMultiSelected(j))

{

//add this code

wdContext.nodeCn_Table().setLeadSelect(j);

entry =wdContext.currentCn_TableElement();

wdContext.nodeCn_Table().removeElement(entry);

}

}

Regards,

Sunitha

Former Member
0 Kudos

Hi Satya,

Your code has removed the previous error and is working fine, but still two issues are left :-

1. There is performance issue with your code (very slow execution). But, I will check that again, as it may be server problem also.

2 . When I delete the last row in the table (single or multiple), I get the following error :- java.lang.NullPointerException

Can you throw some light on this.

Regards,

Nikhil

Former Member
0 Kudos

hi,

instead of lead==i in the condition try writing wdcontext.node<>.isselected(i);

Regards,

Satya.

former_member197348
Active Contributor
0 Kudos

Hi Nikhil,

When deleting the records from the table, iteration should be in reverse order.

Can you try this, please?

for (int i = wdContext.nodeCn_Table().size() - 1; i >= 0; --i) {
if (wdContext.nodeCn_Table().getLeadSelection() == i
|| wdContext.nodeCn_Table).isMultiSelected(i))
{
wdContext.nodeCn_Table().removeElement(
wdContext.nodeCn_Table().getElementAt(i));
}
}

In Satya's code, the condition in for loop causing the problem. So try to change it as per my code.

Regards,

Siva

Edited by: Siva Rama Krushna on Oct 6, 2008 7:27 PM

Former Member
0 Kudos

Hi,

Yes try with reverse iteration, as said above I also got same error like this, but when used reverse iteration it got solved.

Regards

Raghu

Former Member
0 Kudos

hi nikhil,

u can follow the previous code which i have given

but with some changes

change the selection mode of the table to 'auto'

and the selection cardinality to 0..n

initialized lead select = 'true'.

it should work now!

Regards,

Satya.