cancel
Showing results for 
Search instead for 
Did you mean: 

Event Handling

Former Member
0 Kudos

There is a table in which i have a drop down.

On select of the drop down I need to populate another drop down in the same of the row of the table.

For this i need to get the element in which the drop down is selected.

Which is not possible inside the OnSelect of the Drop down

Please suggest a way in which I can get the element / any other way that i can find resolution for the above scenario..

Regards

Arjun Nair

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

you can't use the currentElement - that's right.

You have to use parameter mapping.

Add a parameter nodeElement of type IWDNodeElement to the action which is set for the onSelect event and to the corresponding event handler.

Then, in the View Editor, right-click on the DropDownByIndex and select Parameter Mapping from the context menu. Here you can map the parameter nodeElement from the event to the corresponding parameter of your Action by drag and drop.

In the event handler, nodeElement is the element of the row, in which the action was triggered. You have to cast nodeElement to the specific type of your context node to get typed access to the attributes.

Hope this helps,

Bernd

Edited by: Bernd André Stapel on Oct 12, 2011 9:00 AM

Former Member
0 Kudos

Bernd and Robin

Thanks for the immediate and apt replies.

Robin

Because of you I explored a lot and could study.

Bernd,

You got it man.thanks for solving my problem

Can I also know how to get the index of a element.

Regards

Arjun Nair

Former Member
0 Kudos

Hello,

I'm happy that I helped you.

If you have already got the node element which interests you, use it's index() method

If you like to get the index of the selected element in your DropDownByIndex, I think you have to do the same as you have done with the nodeElement. Add a parameter named index to your onSelect action and event handler and do Parameter Mapping to the corresponding parameter of the onSelect event.

Have a nice day

Bernd

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

Hi Arjun,

I'm not quite sure why you couldn't get the element of the dropdown in the onSelect event... In the event handler, you are perfectly able to get the selected value of the dropdown (and thus the value of the bound attribute in your table context) and based on that value you should be able to populate the second dropdownbykey within the same event handler.

Just be careful, since selecting a different row in your table (which might have a different selected value in the first dropdown) must also repopulate the values of the second dropdown for that row

Former Member
0 Kudos

Hi Robin,

I think you have not got the scenario properly

It's a dropdownByIndex UI element.

Scenario:

I have a table with 4 elements suppose.

The 2nd element is leadSelected.(currentElement)

Suppose the user clicks on the dropDown if the 3rd element (i.e. not the leadSelect),the OnSlelect event of this particular dropDown is triggered

So,

1.I cannot access the particular dropDown using the currentElement property of the table.

2.Since I cannot access the correct element(i.e. 3rd element)element, I cannnot populate the other dropDown.

1.Please suggest me how to access the 3rd element that is not leadSelected.

2.Can i write multiple Event handler where in I can access from which the event is triggered

Thanks

Arjun Nair

Qualiture
Active Contributor
0 Kudos

Hi Arjun,

If your table root node is non-singleton, you could use the following in your onSelect event handler:

IDropDownElement yourSelectedDropDownElement = wdContext.currentDropDownElement();
ITableElement tableRowElement = yourSelectedDropDownElement.node().getParentElement();

If your table node is singleton though, I believe it will always return the lead selection...

Former Member
0 Kudos

Sorry Robin


IDropDownElement yourSelectedDropDownElement = wdContext.currentDropDownElement();
ITableElement tableRowElement = yourSelectedDropDownElement.node().getParentElement();

This code is not working in my scenario.

Its getting the value of the dropDown of the that is lead Selected...

But I need the value of the dropDown from where the its selected.

For this I think that i need to know from where is the source of the event.

Regards

Arjun Nair

Qualiture
Active Contributor
0 Kudos

Hi Arjun,

That happens when your table node is of type singleton. My approach will only work with non-singleton nodes unfortunately

Former Member
0 Kudos

Robin

The Structure is

Context

--Tab_node

-


TableNode

-


attr1

-


attr2

the tab node is Singleton

But table node is Non-Singleton (i.e. false)

I this is the structure and property that you had suggested.

Regards

Arjun Nair

Qualiture
Active Contributor
0 Kudos

Hi Arjun,

Context

--Tab_node

-


TableNode

-


attr1

-


attr2

If Tab_node is what represents the table, and TableNode represents the values in the dropdownbyindex element, then Tab_Node should be non-singleton

(Upon selecting the TableNode element from the dropdown, you will need to get the parent Tab_Node, which should be non-singleton)

Former Member
0 Kudos

Context

--Tab_node

-


TableNode

-


DropDownNode1

-


attr1

-


attr2

-


DropDownNode2

-


attr1

-


attr2

Sorry A little correction.

The tableNode represents the table and its a NON Singleton

Regards

Arjun Nair

Former Member
0 Kudos

Context

--Tab_node

-


TableNode

-


DropDownNode1

-


attr1

-


attr2

-


DropDownNode2

-


attr1

-


attr2

Sorry A little correction.

The tableNode represents the table and its a NON Singleton

Regards

Arjun Nair

Qualiture
Active Contributor
0 Kudos

That's odd... in that case it should work...And according to the API it should work too:

In case of singleton nodes, it is the parent's lead selection element. In case of non-singleton, the node exists once for each element of the parent and this method returns exactly this element

http://help.sap.com/javadocs/NW04S/SPS09/wd/com/sap/tc/webdynpro/progmodel/api/IWDNode.html#getParen...

Not sure what else goes wrong here...

Are you able to use a DropDownByKey instead? That way you can always refer to the current element

Former Member
0 Kudos

Thanks Robin,

I m too not sure of the same.

I too read the description that you had sent according which it is correct.

Please look into the code that i have written:

In the <B>View Controller</b>



wdThis.wdGetPrdCrtHQDOCompController().wdThis.wdGetPrdCrtHQDOCompController().function();

In the <B>Component Controller Controller</b>


public void function()
{
	  IWDNodeElement tableRowElement=null;
	  if(wdContext.currentDropDownElement()!=null&&wdContextcurrentDropDownElement().node()!=null)
		   tableRowElement=wdContext.currentcurrentDropDownElement().node().getParentElement();
	  
	  String test="DropDown";
	  
	  String code=tableRowElement.node(test).getCurrentElement().getAttributeAsText("Code");
                {color:green}//here Code is an Attribute in the DropDown{color} 

		  wdComponentAPI.getMessageManager().reportSuccess("Country is not null   leadSelected:"+code);
}

The above is the code that I have used

Please look into and the O/P is a nulll pointer Exception from the tableRowElement