cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Lead selection

Former Member
0 Kudos

Hi Buddies,

I have implenented the following function to delete Rows of a table:

  public void onActionDeleteCustomer(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionDeleteCustomer(ServerEvent)
	  int n = wdContext.nodeE_Customer().size();
	  int leadSelected = wdContext.nodeE_Product().getLeadSelection();
	  for (int i = n-1; i >= 0; --i){
		  if (wdContext.nodeE_Product().isMultiSelected(i) || leadSelected == i){
			  wdContext.nodeE_Product().removeElement(wdContext.nodeE_Product().getElementAt(i));
		  }
	  }
    //@@end
  }

Unfortunately, leadSelected appears to be -1 at all times...

Is there anything else I have to take care about when using lead selection??

Thanks, Johannes

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Just change the pre-decrement operator i to post decrement operator i in your loop and try executing your code.

Regards,

Murtuza

Former Member
0 Kudos

the for statement does make the line

int leadSelected = wdContext.nodeE_Product().getLeadSelection();

return something else...

It's like I said: The leadSelected appears to be -1 at all times...

Why?

Former Member
0 Kudos

Hi,

Change the selection cardinality of the nodeE_Product to 1..n. It seems to be 0..1/n

Regards

Ayyapparaj

Former Member
0 Kudos

How can I do that? The properties tab does not allow me to make changes in this field... Thanks.

Former Member
0 Kudos

Hi,

Is this a model node? This is the reason why you get -1.

One option is you explicitly set the leadSelection to the first Element.

Regards

Ayyapparaj

Former Member
0 Kudos

I figured it out and tested it but it still appears to be -1...

Former Member
0 Kudos

Yes, it is a model node... How can I set the leadSelection? I only saw LEAD_SELECTION and getLeadSelection, but no setLeadSelection... Thanks, Johannes

vmadhuvarshi_
Contributor
0 Kudos

Johannes,

You are getting the size of nodeE_Customer and leadselection of nodeE_Product. Is this what you intended or is this the reason for surprises?



public void onActionDeleteCustomer(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionDeleteCustomer(ServerEvent)
	  int n = wdContext.nodeE_Customer().size();
	  int leadSelected = wdContext.nodeE_Product().getLeadSelection();
	  for (int i = n-1; i >= 0; --i){
		  if (wdContext.nodeE_Product().isMultiSelected(i) || leadSelected == i){
			  wdContext.nodeE_Product().removeElement(wdContext.nodeE_Product().getElementAt(i));
		  }
	  }
    //@@end
  }

Vishwas.

Former Member
0 Kudos

Awesome, Brother!

I guess too much coding made me blind...

THANKS!!

Answers (1)

Answers (1)

Former Member
0 Kudos

I checked and found out that

  public void onActionOnLeadselection(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionOnLeadselection(ServerEvent)
	  int p = wdContext.nodeE_Customer().getLeadSelection();
    //@@end
  }

returns the correct value... Whys the value -1 in the other function?