cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

Hi,

I have two view in a view set.

In one sceen i have the table and in the other i have form to edit it or delete. In that table i have only one row ,

If i try to delete that value i am getting this error.

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

What might be the problem. I have a context value attribute which will hold the value of the lead selection value in table. I have written this code in the wdModifyview();

if(firstTime)
    {wdThis.Excecutemodel();} 
    else
    {wdThis.Excecutemodel();  
    	   	if((wdContext.currentContextElement().getLeadselct())<0)
    	wdContext.currentContextElement().setLeadselct(-1);
		if((wdContext.currentContextElement().getLeadselct())>=(wdContext.nodeCityElement().size()))
										   wdContext.nodeCityElement().setLeadSelection(0);
										   else
			wdContext.nodeCityElement().setLeadSelection(wdContext.currentContextElement().getLeadselct());}

Regards,

H.V.Swathi

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Swathi,

I think you are getting the error while deleting the table record.

Please try and use following code. I hope this will work.

Step 1: Correct this line of code.


// Take this line of code outside the firstTime loop. Since in both condition anyways you are executing the model. 

wdThis.Excecutemodel();

Step 2: Delete the table record. I am assuming that the node binded with the table is "City"


int size = wdContext.nodeCity().size();
		if(size>0){
			int index = 0; // This means you are deleting the first record (This is as per your requirement).
			
			// You can set whatever value of index you want to delete. This index can be calculated by some logic. 
			// OR if you exactly know which record needs to be deleted then you can set that value to index. 
			wdContext.nodeCity().removeElementAt(index);
		}

Step 3: Set leadSelection


if(wdContext.nodeCity().size()>0){
			wdContext.nodeCity().setLeadSelection(0);
		}
		else{
			wdContext.nodeCity().setLeadSelection(-1);
		}

I hope this work. however I wanted to know one more thing. I am still not clear why have you taken a context attribute which stores a leadSelection?

Thanks and Regards

Pravesh

Answers (2)

Answers (2)

Former Member
0 Kudos

if(wdContext.nodeCityElement().size()<=0)

{

wdContext.nodeCityElement().setLeadSelection(-1);

}else{

if ((wdContext.currentContextElement().getLeadselct())>= (wdContext.nodeCityElement().size()))

wdContext.nodeCityElement().setLeadSelection(0);

else {

wdContext.nodeCityElement().setLeadSelection(wdContext.currentContextElement().getLeadselct());

}

}

i have written this code to solve the error.

Edited by: H.V Swathi on Mar 17, 2009 7:12 AM

Former Member
0 Kudos

Hi,

*In that table i have only one row ,

If i try to delete that value i am getting this error.

*

In your delete action you are deleting the Element in nodeCityElement right?

So you had only one Element and you are deleting it, So now when it comes to wdDoModify

you are not having any element in your node and u have written

wdContext.nodeCityElement().setLeadSelection()

I think it is because of this you are getting the error.