Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

WDRuntimeException: View container UI element represents view container ...

Hi Experts,

My project's demonstration for the customer is coming and I still have a bug in the GUI generation in web dynpro. And my scenario is like this:

I have three web dynpros: Embedded_WDC, Embedder_WDC, Layout_WDC.

The <b>Embedded_WDC</b> has a context node <b>Title</b> with the value attribute <b>Header</b> inside in the <b>Interface Controller</b> having property <b>isInputElement</b> set to true. The <b>cardinality of this node is set to 1..1 and the selection is 1..1</b>. The purpose of this node is to receiving data transfered from outside WDC to inside this WDC through the interface controller, component controller and a view. There is only one view, <b>Embedded_View</b>, in the window <b>Embedded_WDC</b> in this WDC and only a TextView UI Controller to show out the value from Header.Title. This WDC is used inside the <b>Embedder_WDC</b>.

The <b>Embedder_WDC</b> has a context node <b>UsedComponent</b> with the value attribute Name inside. This node is located in the <b>Component Controller</b> and its <b>cardinality is 0..n</b>. There is a view inside this WDC, its name is Embedder_View and inside the window Embedder_WDC .There is a context mapping between this view and the Component Controller for the context node UsedComponent. The <b>Embedded_WDC</b> is added into the Used Web Dynpro Components of the Embedder_WDC with the name <b>Embedded_WDC</b>. This usage life-cycle is set to CreateOnDemand. Because of the specific requirement from the customers, I need to create a tabstrip dynamically with the container having the UI Element ViewContainerUIElement for embedding dynamically the WDC Embedded_WDC. For the dynamic create the component usage and the dynamic tabstrip I have the following lines of code. Before adding these line in the Tab implementation of Component Controller of Embedder_WDC, in the Component Controller of the Embedder_WDC, I added the required Controllers Embedded_WDC(Web Dynpro Component Interface Controller) and created a method named wdDoInitInstance() and add these line of code into it:

    //@@begin wdDoInitInstance()
    /* Get window of itself (container) */
    /* Window name is unqualified name of window (without package) */	
    final IWDWindowInfo currentWindow = wdComponentAPI.getComponentInfo().findInWindows("Embedder_WDC");
    /* Find view inside own window (container) */
    /* You have to assign id in WD window designer -- */
    /* Embedd view, go to "Properties", set id Embedder_View in this case) */
    final IWDViewUsageInfo currentView = currentWindow.getViewUsageByID("Embedder_View");
    /* Create new view container assignment */
    for(int i=0; i<2; i++){
    	IPublicEmbedder_WDC.IUsedComponentElement componentElement = wdContext.createUsedComponentElement();	
    	final IWDViewContainerAssignmentInfo newMainArea = currentView.createViewContainerAssignment();
    	final IWDViewInfo viewMain = (IWDViewInfo)currentView.getView();
    	final IWDViewContainerInfo viewContainer = viewMain.createViewContainer();
    	/* Transfer the name to view controller to setup UI element */
    	/* Create a (default) view usage for component usage information */
    	final IWDViewUsageInfo viewInner = newMainArea.createEmbeddedViewUsage();
    	/* Setup view usage with component usage inofrmation */
    	final IWDComponentUsage cuInner = wdThis.wdGetEmbedded_WDCComponentUsage().createComponentUsageOfSameType("Embeded_"+String.valueOf(i));
    	final IWDComponentUsageInfo cuiInner = cuInner.getComponentUsageInfo();
    	/* Interface view name = unqualified window_name + "InterfaceView"; */    	
    	IWDNodeInfo localNodeInfo = wdContext.getNodeInfo().addChild("localTitle"+String.valueOf(i), null, true, true, false, 
                                false, false, true, null, null, null);
    	localNodeInfo.addAttribute("Header", "");
    	IWDNode localNode = wdContext.wdGetAPI().getRootNode().getChildNode("localTitle"+String.valueOf(i), IWDNode.LEAD_SELECTION);
    	IWDNodeElement localElement = localNode.createElement();
    	localElement.setAttributeValue("Header", "Header "+ String.valueOf(i));
    	/* Get the InterfaceController of used Component */
    	IExternalEmbedded_WDCInterface usedInterface = (IExternalEmbedded_WDCInterface)cuInner.getInterfaceController();
    	IWDNodeInfo referencedTitleNodeInfo = usedInterface.wdGetAPI().getContext().getRootNode().getChildNode("Title", IWDNode.LEAD_SELECTION).getNodeInfo();
    	referencedTitleNodeInfo.setMapping(localNodeInfo, true);
    	/* Mark view usage as default */

Then I add the rest of code for dynamic generation in the method wdDoModifyView of the view Embedder_View in WDC Embedder_WDC.

//@@begin wdDoModifyView

	IWDTransparentContainer root = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
	IWDTabStrip generatingTabStrip = (IWDTabStrip)view.createElement(IWDTabStrip.class,"GeneratingTabStrip");
	for(int i=0;i<2;i++){
		IWDTab generatingTab = (IWDTab)view.createElement(IWDTab.class, "Tab"+i);
		IWDCaption generatingHeader = ((IWDCaption)view.createElement(IWDCaption.class, "Header"+i));	
		generatingHeader.setText("Tab "+(i+1));

		//if (i == 0)
			final IWDViewContainerUIElement container = (IWDViewContainerUIElement)view.createElement(IWDViewContainerUIElement.class,null);

In the tab <b>Properties</b> of <b>Interface controller of Embedder_WDC</b>, I added Embedder_WDC as a required controller. Then I added a method in the interface controller with the name <b>wdDoInitInstance</b>. In the entry of method wdDoInitInstance in the tab implementation of Interface controller, I added a following line of code:


This will help me to call the method wdDoInitInstance in the Component Controller of Embedder_WDC from outside, in the next case is from the Layout_WDC.

In the <b>Layout_WDC</b>, I have no context node. The WDC <b>Embedder_WDC</b> is added into Used Web Dynpro Components with the name <b>Embedder_WDC</b>, its <b>life-cycle is manual</b>. There is a <b>ViewSet named Layout (Type: GridLayout with 1 column, 2 rows)</b> and a <b>view named Main</b>, having a Button UI Element named id Navigation and a plug-out named NavigateToEmbedder, embedded into cell[1,1]. In cell[2,1] I embed a view with the option <b>Embed Interface View of a Component instance</b> which is the <b>Embedder_WDCInterfaceView</b>. Its <b>default property in the viewset Layout is set to false</b>. A navigation link is set between the plug-out NavigateToEmbedder of view Main in cell[1,1] and the plug-in Default of the Embedder_WDC.Embedder_WDCIterfaceView. The point is at the run-time, the view Main will appear first with the button Navigation. Then end-users click on this Button it will be navigated to the embedded view Embedder_WDC.Embedder_WDCInterfaceView. For this, I create an action for the button Navigation. The action name is Navigate and Fire plug for this action is NavigateToEmbedder, Event handler is Use default and without parameters. In the required Controllers of view Main, I added Embedder_WDC, both Embedder_WDC ( Web Dynpro component usage) and Embedder_WDC (Web Dynpro Component Interface Controller) is checked. Then I go to event handler onActionNavigate in the tab Implementation of view Main and add these line of code:

	/* I want the life-cycle of the Embedder_WDC created manually 
	so that the dynamically created component usages of Embedded_WDC 
	inside the Embedder_WDC will be destroy after the Embedder_WDC is delete as the following code. 
	The reason I do this is to get away from checking and manage 
	the existing dynamically created component usages of Embedded_WDC. In the complex case, it will in the numbers.*/


Then I create an application with Referenced Web Dynpro Component is Layout_WDC - gml, Interface View is Layout_WDCInterfaceView and Startup Plug is Default. At run time it shows the contents of the view Main, as it is supposed to run like that. Then I click on button Navigation it navigates to the Embedder_WDCInterfaceView. This is the result as I want. But when I click on the button Navigation again, it raises the error. " View container UI element 1 in view EmbedderView of component Embedder_WDC represents view container -525834110_0 which does not contain a view". This surely only appears on the second time click on the Navigation Button, also means that the code of delete and re-create the component Embedder_WDC runs.

Would you please to create the DC project in local development like I described to test it.

Please help me out of this error ASAP. I really need a soon reply for this.

Thanks you in advance.

Tran Vu

Not what you were looking for? View more on this topic or Ask a question