on 11-11-2008 12:02 PM
Hi Experts,
I'm using 10 buttons all are having common action('click'). when i click a button the 'text' value of the button should pass to a function.So the action is same but the passed value will be the 'text' value of the corresponding button. I don't know how to get the 'text' property of a button in coding. Kindly help me to solve this problem.
Thanks and Regards
Basheer
Hi,
For getting the text value property of a button after the Button click you can write the following code in wdDoModify view of view:
IWDButton button = (IWDButton)view.getElement("<Button id>");
button.getText();
But i am not sure how you distinguish between which button is clicked ,Because you are using same event handler for all of them.
Siddharth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
bind the button text property with context attribute of string.
InDoinit of view set the required name.
when ever you require you can get it like this,
wdContext.currentContextElement().getButtonName();
Regards,
ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
My event is like this.
public void onActionclick(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
String s = ? ; // should get the 'text' property of clicked button
fillInput(s); // function to be called
}
The called function is,
public void fillInput( java.lang.String id )
{
String str=wdContext.currentContextElement().getNum();
str = str + id;
wdContext.currentContextElement().setNum(str);
}
How can i get the 'text' property value of the corresponding button. Click action should be common to all buttons.
Thanks and Regards,
Basheer
I am not sure why you need the (localized) button text in the action handler but you can achieve this using event parameter mapping:
wdDoModifyView(...)
{
if (firstTime)
{
/* assuming the buttons are named "Button1", "Button10" */
for (int i = 1; i <=10; ++i)
{
IWDButton button = (IWDButton) view.getElement("Button" + i);
button.mappingOfOnAction().addParameter("text", button.getText());
}
}
}
Now if you add a parameter "text" of type string to the common action handler, it will contain the text of the pressed button.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.