on 09-12-2007 10:56 AM
hi everyone
I am getting the following error:Exceptionjava.lang.IndexOutOfBoundsException: Index: 0, Size: 0
in the following code can someone pls advice me the reason for this error
for(int index=0; index<=wdContext.currentSerachMaterialListElement().nodeCompoItems().size(); index++)
{
wdThis.wdGetAPI().getMessageManager().reportSuccess("index"+index);
double partWeights = Math.floor(wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).getKwmeng().multiply(wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).getBrgew()).doubleValue());
wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).currentVnBOM_DetailsElement().setVaWeight(partWeights);
grossWeightParts +=partWeights;
double noOfPallets = wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).getKwmeng().divide(new BigDecimal(wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).getMaxqty()),0).doubleValue();
wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).currentVnBOM_DetailsElement().setVaNoOfPallets(noOfPallets);
totalPalletsRequired += noOfPallets;
palletsGrossWeight += Math.floor(new BigDecimal(String.valueOf(noOfPallets)).multiply(wdContext.currentSerachMaterialListElement().nodeCompoItems().getCompoItemsElementAt(index).getBrgew_P()).doubleValue());
}
wdThis.wdGetAPI().getMessageManager().reportSuccess("aftr 2nd for loop");
totalGrossWeight = grossWeightParts + palletsGrossWeight;
wdContext.currentSerachMaterialListElement().nodeVnTruckNode().currentVnTruckNodeElement().setVaGrossWeight(grossWeightParts);
wdContext.currentSerachMaterialListElement().nodeVnTruckNode().currentVnTruckNodeElement().setVaPalletsGrossWeight(palletsGrossWeight);
wdContext.currentSerachMaterialListElement().nodeVnTruckNode().currentVnTruckNodeElement().setVaTotalGrossWeight(totalGrossWeight);
wdContext.currentSerachMaterialListElement().nodeVnTruckNode().currentVnTruckNodeElement().setVaTotalPallets(totalPalletsRequired);
my first report success in which index value is cummin 0 n size of node is also 0
but its not cummin out of the for loop its giving exception in the for loop
thanks & regards
jaspreet
Hi
Since in the for loop you are checking for index<=..... its throwing this exception.
Please change it to index<......
Regards
Akshaya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try this
for(int index=0; index<wdContext.currentSerachMaterialListElement().nodeCompoItems().size(); index++)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jaspreet,
Loop over this and try,
<b>for(int index=0; index<=wdContext.nodeCompoItems().size(); index++)</b>
Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jaspreet,
Please check whether node <b>wdContext.currentSerachMaterialListElement().nodeCompoItems().</b> has elements in that or is empty before trying to access its elements. There is an API method available.
Regards,
Ganga.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.