on 06-16-2008 10:49 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ayyapparaj,
i have alreday created buttons, i'm not creating it dynamically. In that case how to know which button was clicked. Say that i'm having 5 buttons btn1, btn2, btn3, btn4, btn5. And i have mapped all this buttons to same action "btn_click" with a parameter "id".
then how to know which button is clicked? help me out with detailed procedure..
Thanks ,
Suresh
wdDoModifyView(...)
{
if (firstTime)
{
for (int i = 1; i <=5; ++i)
{
IWDButton button = (IWDButton) view.getElement("btn" + i);
button.mappingOfOnAction().addParameter("id", button.getId());
}
}
}
Or better: If you have an IDE that contains the parameter mapping editor, use it and don't write code.
Armin
Hi ,
See the link.... It will help u..
https://forums.sdn.sap.com/click.jspa?searchID=12926782&messageID=5401932
Regards,
Sunitha Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.