cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic ViewContainerUIElement

Former Member
0 Kudos

Dear all,

I have a question about the thread here:

This is the code that's working:


      IWDWindowInfo windInfo = wdComponentAPI.getComponentInfo().findInWindows("TreeCompWindow");
      IWDViewUsageInfo viewUsageInfo = windInfo.getDefaultRootViewUsage();
      
      IWDComponentUsage detailsCompUsage = wdThis.wdGetDetailsComp2ComponentUsage();
      IWDComponentUsageInfo detailsCompUsageInfo = detailsCompUsage.getComponentUsageInfo();
      
      IWDViewContainerAssignmentInfo viewContAssInfo = viewUsageInfo.findInViewContainerAssignments("2");
      IWDViewUsageInfo embeddedViewUsage = viewContAssInfo.createEmbeddedViewUsage();
      embeddedViewUsage.setComponentUsage( detailsCompUsageInfo );
      embeddedViewUsage.setView( detailsCompUsageInfo.getUsedComponent().findInInterfaceViews("DetailsCompInterfaceView") );
      log.debug("embeddedViewUsage view: " + embeddedViewUsage.getView().getName() );
      viewContAssInfo.setDefaultViewUsage( embeddedViewUsage );
      log.debug("view cont assignment view container: " + viewContAssInfo.getViewContainer().getName() );
      wdContext.currentContextElement().setViewContainerName( viewContAssInfo.getViewContainer().getName() );
      wdContext.currentContextElement().setViewUpdated( true );

The code is placed in a separate method. When i call the method from wdDoInit in my component controller it works, when i call the same method after clicking a button, nothing happens. No error is thrown or so. but i just dont see the embedded interface.

Kind regards,

J

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Joren

Let me clarify my previous post a little bit. The dynamic creation of a view usage shall be executed before initialization of the view - container for the view usage. This does not mean you cannot put the code in button's event handler, but you have to make sure the view-container is not yet created when the code will work.

Example:

View A: contains ViewContainerUIElement.

View B: view that shall be embedded into the container.

View C: view with a button. When the button is clicked we shall navigate to A.

Initially only view C is shown, A and B are not created yet. User clicks button on view C. In the event handler you execute the code which creates and embeds usage of B into A dynamically. When the code has been done you fire navigation link to view A. Finally navigation comes to A, A is being created and initialized first time. A is shown on a display with B embedded inside.

BR, Siarhei

Former Member
0 Kudos

Thank you for the detailed explanation.

Is this approach also possible when I have a tabstrip to which i want to dynamiccally add tabs (not problem), but each tab contains a viewcontaineruielemtn that embeds an interface view of a used component. (all viewcontaineruielements exist in the same view here)

Kind regards,

J.

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Joren

It's possible. But you have to separate the code that creates view usages from the code which creates ViewContainerUIElement (s).

You have to create view usages in advance (in component controller's wdDoInit(), for example) and have to store created view container usage names somewhere. You can store the names in the context or in some Java variable or a map:

/* Transfer the name to view controller to setup UI element */
wdContext.currentContextElement().setViewContainerName(vciViewContainer.getName());

Then in a view controller with your tabstrip place the code which creates ViewContainerUIElement (s) dynamically. The code will use usage names stored previously:

// create View Container
IWDViewContainerUIElement viewExtDetails = 
	(IWDViewContainerUIElement) view.createElement(
		IWDViewContainerUIElement.class, null);
viewExtDetails.setViewContainer(wdContext.currentContextElement().getViewContainerName());
...

See post from Valery Silaev in the thread:

BR, Siarhei

Former Member
0 Kudos

Hello,

This way of working is exactly what i was trying now and it seems to work. Thanx alot for the help!

Kind regards,

J.

Former Member
0 Kudos

A next issue i have can be found here:

Kind regards,

J.

Answers (1)

Answers (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi J

>When i call the method from wdDoInit in my component controller it works, when i call the same method after clicking a button, nothing happens.

The code shall be executed before View creation/initialization. The wdDoInit in component controller is very likely executed before the view creation. That's why it works. You cannot put the code in the view controller at all.

BR, Siarhei