cancel
Showing results for 
Search instead for 
Did you mean: 

Set eventhandler dynamicly on runtime like in "normal" ABAP

florian_halder
Participant
0 Kudos

Hi Experts,

is it possible in web dynpro to set eventhandlers on runtime like in "normal" ABAP?

There is the following scenario, I have dynamically embedded a component B in the component A and now I want to handle an event of component B in component A. I can't set the eventhandler on design time because the component usage doesn't exist at that time.

Or is eventhandling maybe the wrong way and I have to do with plugs? But when I do the dynamic binding I can only set the outbound plug of A and the inbound plug of B and not the other way.

  
LOOP AT wd_comp_controller->gt_component_usages ASSIGNING <ls_cmp_usage>.
    lo_api_main->prepare_dynamic_navigation(
     source_window_name          = 'MAIN_WINDOW'
     source_vusage_name          = 'MAIN_VIEW_USAGE_0'
     source_plug_name            = 'TO_V1'
     target_component_name       = <ls_cmp_usage>-used_component 
     target_component_usage      = <ls_cmp_usage>-component_usage_name 
     target_view_name            = 'MAIN_WINDOW'
     target_plug_name            = 'DEFAULT'
     target_embedding_position   = <ls_cmp_usage>-embedding_position "'MAIN_VIEW/VC1'
     ).
  ENDLOOP.

I read a lot of threads about dynamic components usage etc. but did't find a solution.

Many thanks in advance

Florian

Accepted Solutions (0)

Answers (1)

Answers (1)

florian_halder
Participant
0 Kudos

.....I found the answer at the Demo WDR_TEST_CMP_USAGE_GROUP.

This is the code for adding a eventhandler to a component usage:


      wa_cmp_usage-component_usage->add_event_handler(
            listener        = l_component_api
            handler_name    = 'HNDL_DATA_SELECTED'
            controller_name = 'INTERFACECONTROLLER'
            event_name      = 'DATA_SELECTED' ).

And you have to define a eventhandler in the component controller without a specific event.

Maybe this answer could help someone else.

Regards

Florian