Skip to Content

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

Component Usage (Urgent)

Hi All,

Can a view ui container contain more than one component instance. If so at runtime can i choose any one of the instance and create the component and display it.

Mahesh

replied

Hi Mahesh,

Regarding your question:

> Hi Maksim,

> Thanks for that project. I need some clarification

> regarding the Webdynpro Component Interface which u

> have created in the project ---> ViewContainerChild.

> What is it and the uses of it. If ther is any other

> examples or tutorials, please send in.

> Mahesh

Unfortunately I don`t know any tutorials or examples about how to use Web Dynpro Component Interfaces but I will try to explain the main idea behind: Web Dynpro Component Interface is very similar to plain Java interface - you describe some methods and after in your you class you must implement them.

So, you can create Web Dynpro Component Interface, describe context structure, methods, events for component interface controller, create one or more Interface View Definitions and used models. Afterwards in your Web Dynpro Component you declare new created Web Dynpro Component Interface as Implemented Interface and all metadata is copied (Interface Views, Used Models, etc.) and you have to implement methods, event handlers and so on.

In my example I use Web Dynpro Component Interface in Main component as Used Web Dynpro Component and embedd Interface View Definition to ViewContainerUIElement. But exact implementation you will specify on run-time using code:

final String componentName = "com.sap.sdn.child.child1.Child1";//full name of component including package

final IWDComponentUsage usage = wdThis.wdGetViewChildComponentUsage(); 

if (usage.hasActiveComponent() && !componentName.equals( usage.getComponentUsageInfo().getName()) ) {
	usage.deleteComponent();
}

if (!usage.hasActiveComponent()) { 
	try{   
		usage.createComponent(componentName);
	} catch(WDRuntimeException e) {
		wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
	}
} 

I hope now it is clear.

Best regards, Maksim Rashchynski.

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