cancel
Showing results for 
Search instead for 
Did you mean: 

Get element that triggered action

Former Member
0 Kudos

Hello,

Does anybody know how to find out which element on the screen triggered the action? Within action method I need to know which element triggered the action.

Elements are created dynamically and action to them is bound during run time.

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Example: You have 2 buttons "B1", "B2" and both are assigned the same action. How to know in the action handler which button was pressed?

Solutions: Event parameter mapping

B1.mappingOfOnAction().addParameter("Button", "B1");
B2.mappingOfOnAction().addParameter("Button", "B2");

Declare an action parameter "Button" of type String. Then at runtime, this parameter will contain "B1" or "B2" depending on the button that was pressed.

Armin

Former Member
0 Kudos

Hello Armin,

This is for ABAP WebDynpro.

B1 is an ID that I assign to a button during creation, right?

Thanks.

Former Member
0 Kudos

"B1" is the ID of the first button in this example, B1 is a reference to the button (in wdDoModifyView()) which you can get by calling method view.getElement("B1").

WD ABAP should have similar methods, I don't know the exact syntax.

Armin

Former Member
0 Kudos

Hello Amin,

I am very clear on wdDoModiryView is here for.

I thougth that at the time of creation of a button I assign an id to it. For example MyId="5234523452345"

Than, in action handler I add a parameter with the same name as I created - MyId of type int. So when the action is called I get reference to ID of an element that triggered that action, correct?

If so what is wdDoModifyView is for?

Could you please comment?

Thank you

Former Member
0 Kudos

I don't understand the question "If so what is wdDoModifyView is for?".

In WD Java, this method is the only place where you can create and access view elements, I assume this is similar in WD ABAP.

So if you want to create buttons programmatically or get a reference to an existing button and define an event parameter mapping (as in my example), this must be done inside method wdDoModifyView().

Armin

Former Member
0 Kudos

Hello Armin,

Not sure about Java WebDynpro but in ABAP you can create a global reference to the view and access it anywhere, so it does not have to be in wdDoModifyView.

Former Member
0 Kudos

Hello Armin,

I awarded you some points.

I was able to get reference to the element that triggered the action partially with your suggestion.

Thank you.

Answers (0)