cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

table A -

emailid date-in sender recipient

Table B

attachementid attachmentname

i have problem with another issue

i have a master (table) detail (text and textview)

table is bind to nodetable (model)

detail is bind to nodedetail (model)

everytime when i run the i clicked the row,

i want the details to show out....

if i replace with this

IPrivateMailInboundView.IEmailInCommandBeanElement element=wdContext.nodeEmailInCommandBean().getEmailInCommandBeanElementAt(i);

wdContext.currentTablesEmailInElement().setDateIn("abc");

it works ok ..it will change the table row column [date-in] to "abc"

but my intention is to change the detail table attachement-name


public void onActionrowSelected(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionrowSelected(ServerEvent)
	int n=wdContext.nodeTablesEmailIn().size();
	int leadSelected=wdContext.nodeTablesEmailIn().getLeadSelection();
	for(int i=n-1;i>=0;--i){
		if(wdContext.nodeTablesEmailIn().isMultiSelected(i) || leadSelected==i){
		
       
			IPrivateMailInboundView.IEmailInDetailsCommandBeanElement elem=wdContext.nodeEmailInDetailsCommandBean().getEmailInDetailsCommandBeanElementAt(i);
			wdContext.currentEmailInDetailsCommandBeanElement().setAttachmentName("abc");
			
			}
		}
    //@@end
  }

#1#java.lang.IndexOutOfBoundsException: Index: 5, Size: 0

Accepted Solutions (0)

Answers (4)

Answers (4)

balaji_bodagala5
Participant
0 Kudos

Hi ,

can u try like this

check the intial value of the node then only u can enter the loop

and in the for loop n>0

like

if(n>0)

{

for(i=n-1;n>0;i-- )

{}

}

Thanks,

Balaji

Former Member
0 Kudos

yzme,

Seems that you have trivial coding error if first line of "IF" statement:


IPrivateMailInboundView.IEmailInDetailsCommandBeanElement elem 
  =  wdContext.nodeEmailInDetailsCommandBean)
        .getEmailInDetailsCommandBeanElementAt(<b>i</b>);

You are using index <b>i</b> to access inner node, while this is index of outer node.

Also you do not access nested node elements correctly.

So try this:

1. Make sure your nested node for details is non-singleton and has cardinality 1..1

2. Write your code as following:


public void onActionrowSelected(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
  //@@begin onActionrowSelected(ServerEvent)
  final IPrivateMailInboundView.ITablesEmailInNode node = wdContext.nodeTablesEmailIn();
  int n = node.size();
  int leadSelected = node.getLeadSelection();
  for(int i=n-1;i>=0;--i) {
    if  ( node.isMultiSelected(i) || leadSelected==i ) {
      final IPrivateMailInboundView.ITablesEmailInElement elEmail = 
        node.getTablesEmailInElementAt( i ); 
      IPrivateMailInboundView.IEmailInDetailsCommandBeanElement elDetails 
        = elEmail.nodeEmailInDetailsCommandBean().getEmailInDetailsCommandBeanElementAt(0);
      elDetails.setAttachmentName("abc");
    }
  }
  //@@end
}

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi yzme,

If you mean to say that it may happen that there are 'no details' (i.e. The context node "nodeEmailInDetailsCommandBean" may not contain any data init ) for a selected <u>email id</u> in the table populated by node TablesEmailIn, then you can catch the ArrayOutOfBounds exception for that piece of code and then display a message regarding that.

This can be done as:

try

{

..... your code

} catch (ArrayIndexOutOfBoundsException e) {

e.printStackTrace();

wdComponentAPI.getMessageManager().reportWarning("No Details found");

}

Regards,

Alka.

Former Member
0 Kudos

Hi,

The context node "nodeEmailInDetailsCommandBean" may not contain any data init.

In your code "n" refers to nodeTablesEmailIn but in the loop your are trying to access another node. So check this once.

ArrayIndexOutOfBounds exception coming bcose you are trying to access nodeElement which is not there !!!

Regards, Anilkumar

Former Member
0 Kudos

you have identify what i have identify..

yet ...the problem is i don't know how to handle this

onleadselect...probably..i need to use the to loop...

but when i click on the row,i need my details - attachment name to show out...in detail table.....

what do you think i should do

The context node "nodeEmailInDetailsCommandBean" may not contain any data init

CORRECT IDENTIFY

In your code "n" refers to nodeTablesEmailIn but in the loop your are trying to access another node. So check this once

CORRECTLY IDENTIFY