cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Views depending on URL parameters

Former Member
0 Kudos

Hi Experts,

I have to dynamically render a view to a view container depending upon the url parameters at start-up.

If the url parameter is 'E' then the ESS version of screen should appear and if an 'M' is passed it should show the view for the MSS version.

For this I have created 1 main View which contains a 'View Container', and 2 Views as the ESS and MSS screen. I have embedded views and defined plugs accordingly.

But the problem lies in the fact that the Window's 'Startup event handler' is called after the initiation of the View and Window Controllers, hence I am not getting the a place read the url parameter before that, and thus I cannot dynamically decide which view to embed to the container( fire the correct outbound plug) at start up.

Please suggest, as how I can get the url parameters beforehand and decide which view to embed to the View Container at startup.

Thanks

Akashdeep

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks guys for Your answers

Former Member
0 Kudos

Hi,

What i would do is in addition to what you already have, create a new view V-Channel and embed this view as default view in the Window.

Create 2 outbound plugs (to_view1 , to_view2)

Create a event in component controller like event_name is NAVIGATE and the parameter is TO of type string.

Create a method go_navigation with parameter destination of type string.

Write your code in this method to fire the Navigation event filling the TO parameter with destination.

In the V_Channel subscribe to this event NAVIGATE. and write the code for firing outbound plug to_view1 or to_view2 based on the TO parameter value.

Remember to connect these outbound plugs to the right inbound plugs in the ViweContainerUIElement views.

In the start-up plug event handler method, retrieve the URL parameters and call the Go_NAvigation method filling the right value for the destination parameter.

Former Member
0 Kudos

You can access URL parameters anywhere in the code using the following:

data lv_your_variable type string.

lv_your_variable = cl_wd_runtime_services=>get_url_parameter( name = 'YOUR_URL_PARAMETER' ).

case lv_your_variable.

when 'E'.

fire_plug 1

when 'M'.

fire_plug 2

You need not rely on the hook method. I suggest perhaps the wddoinit method if it makes sense.