Skip to Content
author's profile photo Former Member
Former Member

How to get the Id of the Button which is clicked?

Hi,

I am having some 10 buttons and in the on action property these button i'm opening a popup.

I have mapped all the 10 buttons to same action. so i want to know in onAction which button is clicked.

so how to get the Id of the button clicked in the on action?

Help me out with the detailed code.

Thanks,

Suresh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 09:58 AM

    Hi ,

    See the link.... It will help u..

    https://forums.sdn.sap.com/click.jspa?searchID=12926782&messageID=5401932

    Regards,

    Sunitha Hari

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 10:03 AM

    Hi,

    Create a parameter to the action lets say id of type string

    Do a source mapping as follows

    IWDButton b1 = (IWDButton)view.createElement(IWDButton.class);
    	  //In older verion use addParameter
    	  b1.mappingOfOnAction().addParameter("id","Button1");
    	  b1.mappingOfOnAction().setString("id","Button1");
    
    //Do the same for rest of the buttons
    
    

    Regards

    Ayyapparaj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 16, 2008 at 11:03 AM

    hi Suresh,

    in your case no need to get id of buttons , you can open a window using

    id but it will be a long process.

    you just create a value attribute of type string

    *let you have created value attribute named "myButton" *

    now on every button click you set the value in myButton. like

    wdContext.currentContextElement().setMyButton("your value");

    now check value of button and write your desired code .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:03 AM

    Hi,

    Write this code in the "wdDoModifyView()" 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");
    

    Add the parameter "commandID" to the event handler of ur buttons and it should be of type "String". That will look like:

    public void onActionTest(IWDCustomEvent wdEvent, String commandID){
    
    //here commandID contains the ID of the button which was clicked
    
     wdComponentAPI.getMessageManager().reportSuccess(commandID);
    }
    

    regards

    Surender Dahiya

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.