cancel
Showing results for 
Search instead for 
Did you mean: 

Index Out Of Bounds Exception

Former Member
0 Kudos

Hi forum

I am getting array out of bound exception in the following code:

int intLNodeSize=0;

intLNodeSize=wdContext.nodeVn_DelUserParameters().size();

wdComponentAPI.getMessageManager().reportSuccess("node size"+intLNodeSize);

if(intLNodeSize==1)

{

wdComponentAPI.getMessageManager().reportSuccess("in i=1");

//wdContext.currentVn_DelUser_FlagParameterElement().setVa_DelUser_CheckedFlag(WDVisibility.VISIBLE);

wdContext.nodeVn_Checked().getVn_CheckedElementAt(0).setVa_DelUser_CheckedFlag(true);

}

if(intLNodeSize>1)

{

wdComponentAPI.getMessageManager().reportSuccess("in i>1");

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

{

wdComponentAPI.getMessageManager().reportSuccess("in for loop"+wdContext.nodeVn_DelUserParameters().getVn_DelUserParametersElementAt(i).getVa_DelUser_MainRecordFlag());

if(wdContext.nodeVn_DelUserParameters().getVn_DelUserParametersElementAt(i).getVa_DelUser_MainRecordFlag()==false)

{

//wdContext.currentVn_DelUser_FlagParameterElement().setVa_DelUser_CheckedFlag(WDVisibility.NONE);

wdContext.nodeVn_Checked().getVn_CheckedElementAt(i).setVa_DelUser_CheckedFlag(false);

}

else

{

//wdContext.currentVn_DelUser_FlagParameterElement().setVa_DelUser_CheckedFlag(WDVisibility.VISIBLE);

wdContext.nodeVn_Checked().getVn_CheckedElementAt(i).setVa_DelUser_CheckedFlag(true);

}

}

}

Its goin in the for loop once only when the node size=2.

I am getting the following exception : Index: 0, Size: 0 : Index: 0, Size: 0 : java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

Thanks & Regards

Jaspreet Kaur

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You are looping around nodeVn_DelUserParameters() node and you are gettting the element of this node nodeVn_Checked() in your else condition. This node might have less elements than nodeVn_DelUserParameters().

This might be the problem. Try commenting the below line and check it once ...

wdContext.nodeVn_Checked().getVn_CheckedElementAt(i).setVa_DelUser_CheckedFlag(true);

You are also accessing the element of the same node in if clause too.

Regards,

Murtuza

Message was edited by:

Murtuza Kharodawala

Former Member
0 Kudos

Hi Murtuza

Thanks, I just created the flag element in my del parameter node...its workin now..

Thanks & Regards

Jaspreet Kaur

Answers (0)