cancel
Showing results for 
Search instead for 
Did you mean: 

How to register custom button events to popup?

Former Member
0 Kudos

I'm currently working with popups in Web dynpro ABAP. When creating and opening a popup, we can register an action in the main window, when a certain botton in the popup are clicked, the action in the main window can be performed. But It looks I can only register action for predefined button like OK, Yes, NO..., or register on close action. When I tried to create my own button from web dynpro, I can not findout how to register an action in the main window which is corresponding to this button click.

Is there any experts who can help me with this block? Thank you very much

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Get a reference to your window manager, and create a window object as a popup window. For this, use the method window_manager->create_popup_to_confirm that would return a reference to if_wd_window.

You then need to call the method window->subscribe to button event for each button you wish to have. If you have a yes/no/cancel, subscribe to button event thrice, passing the action as "yes", "no", "cancel" etc. These actions need to be defined separately in the "Actions" tab of your view. The event handlers will be created automatically. After defining the actions, call the method window->open to display your popup window.

Hope this helps.

Regards,

Nithya

Former Member
0 Kudos

Hello,

Thank you for your answer.

Now I have my own button which is a standard abap web dynpro button, how

can I register an main window action for this button? becasue this button is not of type

window popup button. I can find no function to register an event for it.

I can only trigger window->close when the button is clicked, but the action in the main window can not be performed.

mohammed_anzys
Contributor
0 Kudos

Hi

I think , only the predefined set of button works , i mean the list follows

CO_BUTTONS_ABORTRETRYIGNORE

CO_BUTTONS_OK

CO_BUTTONS_CLOSE

CO_BUTTONS_OKCANCEL

CO_BUTTONS_YESNO

CO_BUTTONS_YESNOCANCEL

CO_BUTTON_NONE

CO_BUTTON_ABORT

CO_BUTTON_RETRY

CO_BUTTON_IGNORE

Thanks

Anzy

mohammed_anzys
Contributor
0 Kudos

Hi

Right now in the IF_WD_WINDOW->SUBSCRIBE_TO_BUTTON_EVENT method , the button should of the type WDR_POPUP_BUTTON and it has a value list now.Which means you cannot use your own value for the time being.May be they will be coming up with an enhancement in the future.So till that time, i dont think you will be able to use your own buttons.

Thanks and regards

Anzy

Award points if this answers your question

Former Member
0 Kudos

Hi,

If you are talking about registering an action for a normal button, go to the properties tab of your button element. You would see a field "On Action". You can create your own event there. This will be called when you click the button, and the event handler onaction<event name> method will be generated. Do your processing there.

Regards,

Nithya

Former Member
0 Kudos

Thank you,

But now this action is not in the same view of this button, it is in the main window which the view contains the button is a popup. so do you mean it is also possible to fire the action in the main windows' view via the button in the popup view?

Former Member
0 Kudos

If the popup you mean is just a modal dialog like a prompt for save or seomthing, then it will be in the same window as your main view. You will create a window object and call it in the modal format. It will not be a new view.

But I think you are talking about displaying a view as a popup. In that case, I do not think you can trigger an event in your main view from the popup view. Please explain your requirement a bit.

Regards,

Nithya

mohammed_anzys
Contributor
0 Kudos

Hi

Yes you can trigger an action in the main view through a pop up action.The thing is that , anyways your pop action will be part of your main view ...So in your pop up action you could call your main view method or event ....

like call method mainviewmethod ( ).

Thanks

Anzy

Former Member
0 Kudos

Hi Anzy,

I have the same problem as the OP:

I want to call a popup, which has some input fields and some custom buttons (not only the standard popup buttons). On clicking on one of the custom buttons I would like to close the popup window, i.e., going back to the main screen and - now the difficult part starts - navigate to another screen. This means I would need to fire an outbound plug from the main view.

So far the popup is in another view containing the input fields and buttons. It is created from the main view via create_window - calling a new WD wnidow with the popup view as the default view. In the do init of the popup view I can also register standard button events calling action methods in the main view. This means I can fire a outbound plug from the main view when clicking on one of the standard buttons.

But how to proceed with the custom buttons? The action is processed in the popup view / popup window. How to fire an action on the main view? You write that the popup action is part of the main view. Well, true for the standard buttons. But the custom buttons are processed in the popup view / popup window, arent't they?

Thans for any help

Lars

Former Member
0 Kudos

If this helps.

declare Component Controller Usage in the VIew which is on the pop up window

Declare a Action to the Custom button on the View in the Pop up Window to be handled in the Same View (not MainView ),

Now in the Action Handler, in the Pop up View, you can call a method of the Component Controller since u have declared a usage of it in the View Properties.

From this method of Component Controller , Raise an interface Event say EventA

Declare a EVent Handler in the Main View to catch EventA A and fire Outtbound plug from there ...

SO navigation is

Button on Pop up pressed -> Action handler in the View Pop up->Call method in Component Controller-> Event raised in Component Controller->EVent caught in Main View->Outbound plug fired

See if this works

Former Member
0 Kudos

Hi Anand,

thank you very much - your solution solved perfectly by problem.

Best regards

Lars

Answers (0)