cancel
Showing results for 
Search instead for 
Did you mean: 

Can i change the view embbed in viewContainerUIelement in code?

Former Member
0 Kudos

I have defined a viewContainerUIelement in my MAINVIEW and several VIEWs in my component. Each time, I start the WD application, I need the viewContainer choose one of the VIEWs to show according to some conditions. How can i realize it in my code?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

After Embedding all the required views in the View UI Container , link them through the plugs and fire the relevent plugs of the View which want to display.

Eg, if Embed View A, View B, View C in the Main View,Link these Inbound plugs from the View A, View B ,View C to Main Outbound Plugs .After that call the Relevent outbound plug in the WDOINIT method in the Main View

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Although Navigation Plugs are the correct normal approach, please note that there is also a pure coding approach also. This way not all navigation plugs have to be defined in advance, allowing for really dynamic navigation. For this you can use the method do_dynamic_navigation of the view API:

data:
    l_api_main type ref to if_wd_view_controller.
  data: target_component_name type string,
        target_view_name      type string,
        source_plug_name      type string.
   l_api_main = wd_this->wd_get_api( ).
    try.
        l_api_main->do_dynamic_navigation(
            source_window_name        = 'MAIN'
            source_vusage_name        = 'MAIN_VIEW_USAGE_1'
            source_plug_name          = source_plug_name
            target_component_name     = target_component_name
            target_view_name          = target_view_name
            target_plug_name          = 'DEFAULT'
            target_embedding_position = 'MAIN_VIEW/VIEW_CONTAINER').
        .
      catch cx_wd_runtime_repository .
        raise exception type cx_wdr_rt_exception.
    endtry.

This method even allows you to call external components without declaring a component usage.

Answers (2)

Answers (2)

Former Member
0 Kudos

HI Thomas Jung,

This is very helpful! Thank you very much all the same!

Former Member
0 Kudos

hi Vikranth, it's great! Thank you!