cancel
Showing results for 
Search instead for 
Did you mean: 

Creating views dynamically at runtime

AlexanderOv
Participant
0 Kudos

Hi All.

I'm developing Web Dynpro application (Java). I've created a viewset with type "TLayout90". And now I need to create several views dynamically at runtime in the "Bottom" part of the viewset. Amount of the views depends from some conditions in my program. How can I do that?

Accepted Solutions (0)

Answers (1)

Answers (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Alexandr

This is a classical Webdynpro restriction: creation of views dynamically.

The first problem is a view has to be designed on design-time only. I mean that at least you have to design some view (maybe empty) which you will later add to your T-Layout.

The second problem is a view can be created inside View usage only which is bound to Embedded View UI control. As I remember you cannot create Embedded View controls and bind views to them dynamically. There is not such way officially.

Well, there is some unofficial very tricky way how you can do this, but I will not say about it now.

What I'd recommend you is to create several Embedded View controls on design-time and bind the view to the view usages (also on design-time). The number of usages has to be equal to the maximum usages that you have to ever create. Let me say 10, for example. Make the UI controls invisible by default. Then on run-time you do not need to create any views/usages. Instead you have to manage the controls' visibility only.

BR, Sergei

AlexanderOv
Participant
0 Kudos

Hi Sergei, thank you for your reply.

Now I've got this application and it works perfectly with 3 views in the "Bottom" part. These views were created at design-time and they are shown when necessary.

Unfortunately, number of these views will be changed soon. And this number probably will be changed in future again. That is why I want to create the views at runtime. I want to create one class, e.g. ItemView, and then create so many instances as needed at runtime.

I've tried something like this but it doesn't show the view:



	IWDViewContainerAssignmentInfo vcai =
		wdComponentAPI.getComponentInfo()
			.findInWindows("MainWindow").getDefaultRootViewUsage()
				.findInViewContainerAssignments("Bottom");

	IWDViewInfo item2 = wdComponentAPI.getComponentInfo().findInViews("ItemView");
	
	IWDViewUsageInfo dynview = vcai.createEmbeddedViewUsage();
	dynview.setView(item2);