cancel
Showing results for 
Search instead for 
Did you mean: 

How to Call Event Handler Method in Another view

santhosh_nagavalli
Participant
0 Kudos

Hi Experts,

 

                   Can anybody tell me how to call Event handler Method which is declared in View A ,it Should be Called in

  view B,Thanks in Advance.

Thanks & Regards

Santhosh

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Sandesh,

You can call event handler method of View 1 in View 2 as below


  • Go to events tab of component controller and create an event "ON_CLICK" in component controller
  • Create a method RAISE_EVENT_CLICK in component controller and write the below code

          CALL METHOD wd_this->fire_on_click_evt( )

  • Now, in view1 create an event handler method ON_SELECT and bind it to the event of component controller as below

         

  • Go to VIEW 2 and call the component controller method as below

               wd_comp_controller->raise_event( ).

Now, the event handler method in VIEW1 gets called

-----------------------------------

If you just have to perform the common action of VIEW1 in VIEW2, As suggested by

Create a method in component controller and move the logic to that method  ex: DO_ACTION1 and call in all views as below

WD_COMP_CONTROLLER->DO_ACTION1( ).

Hope this helps you.

Regards,

Rama

Answers (3)

Answers (3)

former_member222068
Active Participant
0 Kudos

Hi Sandesh,

Declare an event in the component controller. ( to call the event in other component, check the column INTERFACE )

Define a method in the component controller

Logic implemented in the method

To call the event in the views of the component

Thanks & Regards,

Sankar Gelivi

former_member184578
Active Contributor
0 Kudos

Hi,

Place the event handler method code of view A in Component controller method and call the component controller method in View B using wd_comp_controller->viewA_method( ).

Regards,

Kiran

Former Member
0 Kudos

hi,

1)    You can make the method EH_ONSELECT as public and static and call this method in viewGS_CM/ADDDOC  using syntax

    impl class name of view GS_CM/DOCTREE=>EH_ONSELECT "method name.

                       

             or

2)The view GS_CM/ADDDOC which contains EH_ONSELECT method has been already enhanced, so I can't execute such kind of operation one more time.

  

                     or

3)If both views or viewarea containing that view are under same window , then you can get the instance ofGS_CM/DOCTREE from view GS_CM/ADDDOC  through the main window controller.

lr_window = me->view_manager->get_window_controller( ).

    lv_viewname = 'GS_CM/DOCTREE '.
  lr_viewctrl ?= 
lr_window ->get_subcontroller_by_viewname( lv_viewname ).

Now you can access the method of view GS_CM/DOCTREE .

Let me know in case you face any issues.





Message was edited by: Laure Cetin Please do not ask for points, this is against the Rules of Engagement: http://scn.sap.com/docs/DOC-18590