cancel
Showing results for 
Search instead for 
Did you mean: 

Identify button that call action

Former Member
0 Kudos

Hi all,

I've a action that was fired by two buttons, how to identify what button that call the action?

public void onActionTest(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionTest(ServerEvent)

???

//@@end

}

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Try to pass different parameter through different buttons,

may be True from one

False fro second

then based on that you can find which button is pressed

try the link for knowing more how to pass parameter through onAction

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/60/1f1f056f057d4d962375efd3c92ed0/frameset.htm">onAction Parameter</a>

Regards

Abhijith YS

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Write this code in the "<i>wdDoModifyView()</i>" method:

//let's say the first button ID is btn1
IWDButton buttonOne = (IWDButton) view.getElement("btn1");

buttonOne.mappingOfOnAction().addParameter("commandID","btn1");

//let's say the second button ID is btn2
IWDButton buttonTwo = (IWDButton) view.getElement("btn2");

buttonTwo.mappingOfOnAction().addParameter("commandID","btn2");

Edit "<i>onActionTest</i>" event handler to add a new parameter to it. Call the new parameter "<i>commandID</i>" and it should be of type "<i>String</i>". Now this will look like:

public void onActionTest(IWDCustomEvent wdEvent, String commandID){
//here <b>commandID</b> contains the ID of the button which was clicked
}

Regards,

Satyajit.

Former Member
0 Kudos

If your IDE already contains the parameter mapping editor, you can do this inside the view designer. Right-click the button in the Outline view and select "Parameter Mapping" to open the editor.

Armin

Former Member
0 Kudos

Hi,

Most probably it won't be possible to determine this. You need to have a seperate action on button2 and button1.

Regards,

Murtuza