cancel
Showing results for 
Search instead for 
Did you mean: 

Change the default view dynamically

Former Member
0 Kudos

Hi,

When a WD application is called, it always displays the view that is flagged as default. Now I need to change the view depending on certain logic (for which I already have a code inside a separate method). How to do this?

I assume that I need to add some code to the window inboung plug handler method, but I am not sure what. Any hints appreciated.

Regards,

Pa

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You have to use viewcontainerUI element to acheive this,

Please follow these steps.

1- Create 2 view controller UI elements on your main view. which will be called first time when the application will be launched. (Right click on root container and click add element and then specity 'view controller UI elements')

2- Create two attributes in view context e.g 'visible_veiw1' and 'visible_view2' with a boolean (char1) data type.

3- Bound the visible property of both view controller UI elements to this visible attribute

4- Now create 2 seperate views which you want to show depending upon certain condition.

5- At this point your component consists of 3 views..one main and 2 others.

6- Now go to windows in the component controller...doube click on window ...on the right hand side you will see your main view...you will see this in tree structure...just expand the tree...here you will see 2 view controller UI elements which you had created on the view..

7- Right click on first view controller UI elements and select embed view. Now here mentioned the view 1 (other than main)...in the same way right click again on the 2nd view controller UI elements and embed the 2nd View.

8- Go to the init method of main view... open the code wizard and check radio button 'Read Context'.

9- Here specify 'visible_view1' attribute which you have created...it will write the code for you...

now suppose it has created a lv_visible_view1 variable for you...in get_attributes method... (repeat 8, 9 step for visible_view2 also)

now here write your own condition...suppose

If ....
  lv_visible_view1 = 'X'  
  lv_visible_view2 = ''
else.

  lv_visible_view1 = ''
  lv_visible_view2 = 'X'
endif.

at the end call set atttibutes method and set lv_visible_view1 and lv_visible_view2

Hope it works.

Answers (1)

Answers (1)

arjun_thakur
Active Contributor
0 Kudos

hi,

you can proceed in this manner:

create a view container UI element in your main view. now embed all the other views in this view container and create fire plugs from main view to the other views. now in the doinit of the main view just check your condition and fire the plug which satisfies your condition.

i hope it helps.

regards

arjun

Former Member
0 Kudos

Thanks for the helpful answers. Basically the solutions that you presented would have been similar to my own solution. Anyhow, I was (and still am) interested if there is a way to dynamically select the first view that is shown (and if this is somehow achievable directly from the window).

Regards,

Pa

arjun_thakur
Active Contributor
0 Kudos

hi Pa,

try to refer this thread:

i hope it helps

regards

arjun