cancel
Showing results for 
Search instead for 
Did you mean: 

Event Handling in Same Component , Fire outbound plug from Component controller

ashish_shah
Contributor
0 Kudos

Hi Gurus,

I want to fire an outbound plug of a View from Component controller's method.

This is the scenario.

  1. I have a component with 2 different views (Say View A and View B )
  2. From View A , on click of a button, i am calling a Confirmation pop up window.
  3. I have subscribed to this Pop window's OK button by assigning an action(Say SUBSCRIBE_OK) .
  4. On click of this OK button, i want to navigate from View A to View B.
  5. I have created an Event in component controller. (Say OK_CLICKED)
  6. In the Action Event Handler Method SUBSCRIBE_OK , i am firing an Event of Comp Controller OK_CLICKED.
  7. I want to handle this event OK_CLICKED , for this i have created an Event Handler method in Component controller (Say OK_HANDLE)
  8. I have also registered this Event handler method in WDDOINIT of Component Controller.
  9. Now in this Event Handler method in Component controller, how do i fire outbound plug of VIEW_A.

This is the code written to register event handler in Component controller's WDDOINIT.

DATA: l_api TYPE REF TO if_wd_component.

l_api = wd_this->wd_get_api( ).

l_api->add_event_handler(

      listener_name    = 'COMPONENTCONTROLLER'

      handler_name     = 'OK_HANDLE'

      controller_name  = 'COMPONENTCONTROLLER'

      event_name       = 'OK_CLICKED' ).

Can you suggest how do i fire an outbound plug of View_A from Component Controller's method?

Regards,

Ashish Shah

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Make the event Public.

Now instead of handling the event in Component Controller, create the event handler in View 1. i.e. OK_HANDLE should be in View 1.

Now in this event handler call outbound plug.

ashish_shah
Contributor
0 Kudos

Hi Khushboo,

I had tried the same thing earlier, it did not work for me then.

However as soon as i added this code in VIEW A's WDDOINIT it worked now.

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
   DATA lo_api_componentcontroller TYPE REF TO if_wd_component.
   lo_api_componentcontroller = lo_componentcontroller->wd_get_api( ).

  lo_api_componentcontroller->add_event_handler(
       listener_name    = 'V_MAIN'
       handler_name     = 'OK_HANDLE'
       controller_name  = 'COMPONENTCONTROLLER'
       event_name       = 'OK_CLICKED' ).

Thanks for your help.

Regards,

Ashish Shah

Answers (1)

Answers (1)

RicardoRomero_1
Active Contributor
0 Kudos

Hi Ashish,

I think you're trying to do it too complicated. If you want to call the view B from the popup called in view A you can do it directly from the action SUBSCRIBE_OK of view A.

Why do you want to do it from component controller?

Anyway if you want to fire an outbound plug from the component controller you can create this outbound plug in your window, add the window as used controller (Properties tab) in your component controller and you'll can fire the plug using the code wizard "Method call in used Controller".

Regards,

ashish_shah
Contributor
0 Kudos

Hi Ricardo,

The only reason , i am using this complicated scenario , is since the pop up window is not a confirmation Pop-Up window , its a window containing a custom view.

Also in this custom view , i have a OK button inside my View, its not a OK button of a Pop Up window.

Thanks for your suggestion about window's plug, i was not aware that i can add Window controller as a used controller in Component controller.

Regards,

Ashish Shah