cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownByIndex: Which drop down sent the event?

Former Member
0 Kudos

Hi

I have a table with to drop downs in each line (DropDownByIndex).

When I select a new value in one of the drop downs, an event is sent with a parameter (index) telling which index of the drop down was selected, but the event doesn't tell which drop down sent the event...

How do I find out which drop down raised the event?

Regards

Jacob

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Jacob,

You need to add parameter to parameter mapping of onSelect event for <b>each</b> dropdown list. In wdDoModifyView put something like:


IWDDropDownByIndex ddbi = ...;
ddbi.mappingOfOnSelect().addParameter("id", ddbi.getId());

and in your action handler add parameter "id". This parameter will contain id of your dropdown.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim

Thanks for your input.

The problem with this solution is, that I can have several rows in the table, each having their own instances of DropDownByIndex1 and DropDownByIndex2.

This means that once the event is fired, I only know which column the drop down is in I don't know which row it's in.

I need to know which row and column the onSelect event was fired from.

Do you understand what I mean?

Regards,

Jacob

Former Member
0 Kudos

Map the (implicit) event parameter "nodeElement" to an action parameter of type IWDNodeElement. Cast this parameter if needed to your specific node element type.

wdDoModifyView():

if (firstTime)
{
  IWDDropDownByIndex dd = (IWDDropDownByIndex) view.getElement("ID-of-drop-down-list");
  dd.mappingOfOnSelect().addSourceMapping
  (
    "nodeElement", /* name of implicit event parameter */
    "selectedElement" /* name of action parameter */
  );
}

Note: This does not work in older releases.

Armin

Former Member
0 Kudos

Hi Armin

Which versions of NW does this work for?

When the event is fired, I don't get any node through (null).

We're using WAS J2EE NW04 SP14 and EP6 SP14.

Cheers,

Jacob

Former Member
0 Kudos

I think since SP13, see also Bertram's nice article

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c092333b-0601-0010-e7af-8c2...

Have you used the correct spelling "nodeElement" in the mapping statement?

Armin

Former Member
0 Kudos

Hi Armin

Thanks a lot.

I followed the link, checked out the example app and now it works.

Superb!

Cheers,

Jacob

former_member286976
Active Participant
0 Kudos

Hi Armin,

I am getting the following error message when i'm trying to do the same.

Error

-


java.lang.ArrayIndexOutOfBoundsException 
com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Failed to convert parameter nodeElement="nodeElement" into a node element

Code

-


doModifyView()
--------------
IWDAction cellEntry = wdThis.wdCreateAction(IPrivateChrtabView.WDActionEventHandler.CELL_VALUE_CHANGE,"");
			
IWDTable iTabFinal = (IWDTable)view.createElement(IWDTable.class,null);
iTabFinal.bindDataSource("NewElements");
iTabFinal.setToolBar(tb);
iTabFinal.setCompatibilityMode(WDTableCompatibilityMode.NW04_PLUS);
		
Iterator itrElement = wdThis.wdGetContext().nodeNewElements().getNodeInfo().iterateAttributes();
int index = 1;
while(itrElement.hasNext())
{
	IWDAttributeInfo iWDInfoElements = (IWDAttributeInfo) itrElement.next();
	IWDTableColumn iTabColFinal = (IWDTableColumn) view.createElement(IWDTableColumn.class,null);
	IWDInputField idk = (IWDInputField)view.createElement(IWDInputField.class,"inp_"+index);
	idk.bindValue("NewElements."+iWDInfoElements.getName());
	idk.setOnEnter(cellEntry);
		
	idk.mappingOfOnEnter().addParameter("colValue",String.valueOf(index));
	idk.mappingOfOnEnter().addParameter("nodeElement","nodeElement");

	iTabColFinal.setTableCellEditor(idk);
	IWDCaption iCapFinal = (IWDCaption) view.createElement(IWDCaption.class,null);
  	iCapFinal.setText(iWDInfoElements.getName());
	iTabColFinal.setHeader(iCapFinal);
	iTabFinal.addGroupedColumn(iTabColFinal);
	index++;
}
container.addChild(iTabFinal);
container.addChild(bt2);

onActionCellValueChange()

-


No action written. Just a success message is printed in this action. But the control is not even coming to this line of code. Before itself the program dumps with the above error message

Hope you can help.

Kind Regards,

Sudeep.

Answers (1)

Answers (1)

former_member286976
Active Participant
0 Kudos

Hello Armin,

I found out the problem.

I have used function addParameter() instead of addSourceMapping() in my code.

Problem is resolved now.

Thanks..

Sudeep.