Skip to Content

How to Call Event Handler Method in Another view

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Feb 28, 2014 at 08:50 AM

    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 @Kiran Kumar Valluru

    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


    1.PNG (13.1 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2014 at 06:23 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 28, 2014 at 08:08 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 28, 2014 at 12:13 PM

    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


    Event.PNG (16.4 kB)
    Event.PNG (10.6 kB)
    Event.PNG (23.3 kB)
    Event.PNG (22.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.