on 2006 Nov 30 3:58 AM
Hi all
I have a problem. I want to bind an action to a button based on the text for that button. I'm changing the text of the button based on the selection criteria.
I've created separe actions. I want to bind the action with button based on the text. Is it possible. If so anybody please help me.
Thanks and Regards
Aparnna
create a parameter for the action say "text".Now map button's text property to this text parameter of the event.
in the wdDomodifyView() write the following code.
IWDButton btn=(IWDButton)view.getElement("Button1");
btn.mappingOfOnAction().addParameter("text",btn.getText());
IWDButton btn2=(IWDButton)view.getElement("Button2");
btn2.mappingOfOnAction().addParameter("text",btn2.getText());
In the onAction method get the value of text parameter and accordingly handle ur code.
Hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry in my previous msg, instead of getAction I coded getElement please ignore it. It should be as below
........... IWDButton button = (IWDButton) view.getElement(IWDButton.class, "buttonid");
........... IWDAction action1 = (IWDAction)view.getAction("action1id");
........... IWDAction action2 = (IWDAction)view.getAction("action2id");
........... If(button.getText().equalsIgnoreCase("App"){
..................button.setOnAction(action1);
..................button.setText("App2");//toggling button text
............}
...........else{
..................button.setOnAction(action2);
..................button.setText("App");//toggling button text
...........}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashutosh
First I was using ToolBarButton in the table. Then it was not working. After that i tried using the normal IWDButton. Then also it didn't work.
When i click on that button the window stays there as such. I've done exactly as u have specified. Did u read my problem? I'm using a dialog window.
Please go through the tutorial links that Anil has given. I've followed that tutorial to create a dialog window.
I've sent a mail to ur mail id.
Regards
Aparnna
Hi Aparna,
You can try this:
1. Create two actions at design time, say action1 and action2
2. In wdModifyView toggle the text of ur Button, and bind action dynamically as follows:
........... IWDButton button = (IWDButton) view.getElement(IWDButton.class, "buttonid");
........... IWDAction action1 = (IWDAction)view.getElement(IWDAction.class, "action1id");
........... IWDAction action2 = (IWDAction)view.getElement(IWDAction.class, "action2id");
........... If(button.getText().equalsIgnoreCase("App"){
..................button.setOnAction(action1);
..................button.setText("App2");//toggling button text
............}
...........else{
..................button.setOnAction(action2);
..................button.setText("App");//toggling button text
...........}
I think this will work
Regards,
Aparna .P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
good
go through this link, i hope this ll help you to solve your problem
/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements
thanks
mrutyun^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aparnna,
Do the foolowing
1.Bind text property of Button to a valueattribute.
2.create an action and bind it tothe button ( Nonned to create many actions )
3.In the action handler,access the vaueattributeand based on the value you can write the logic
Ex :If(wdContext.currentContextElement().getButtonText().equals("Create")
//Do 1
else
If(wdContext.currentContextElement().getButtonText().equals("Save")
Regards,Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anil
My I'm using a dialog window, that pops up when a user clicks a button.
Suppose there are 4 buttons in the main vew.
Application, Module, Version etc.
When a person clicks Application a window comes with all the selectable attributes displayed as a table.
I want the selected values back in the first view.
For each button i want this to happen. Creating a window for each is not a good thing to do(that's my view). So I'm trying to integrate everything in a single window, inside that a single view.
I want separate events to be fired , depending on the button text.
Based on the selection made by the user i want to fetch data from database.
Regards Aparnna
Hi,
Still i feel you can do this by simple context binding instead of complicating the things!!!
You have MainView with 4 buttons...you have 1 view having table.
you can create valueAttribute "ButtonText" on both the views and do context mapping.
in the Tableview(secondview) , you can read the buttontext through context and display the attributes accordingly.
Regards,Anilkumar
Hi Anil
This i've done already.
First i've done this for a single button. Not using this context variable for button text. When i click on that button this window will close and control is transfered to the first view. For a single button everything is working fine.
If you want i'll send the tutuorial i've followed for creating the dialig window.
Regards
Aparnna
Aparna
You can create an object of push button in wdDoModify method
and there on checking certain conditions you can apply actions.
Ashutosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
13 | |
11 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.