cancel
Showing results for 
Search instead for 
Did you mean: 

Create Component Usage at Runtime

Former Member
0 Kudos

Hello,

Is there a possibility to create a Component Usage at runtime?

I have to show one view more than once in a view assembly and put this view in a separate component. Now i want to create Instances (Usages) of this component at runtime to show this view. Is this possible?

Greetings,

Geert

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Geert,

It is possible. To achieve this, u have to create DC project.

First ,create DC project that contains ur component to be reused. Then add that component to its public part.

Then in another DC project in which u need to reuse the component, add the above component to Used DCs.

After that, add the component to be reused to " Used webdynpro components " of ur project.

While adding the component, u can specify the LifeCycle of component as either manual or create on demand.

If u r selecting manual, add the folllowing code to ur controller.

wdThis.wdGet<included component name>ComponentUsage().createComponent();

If u r using createOndemand, then no need to include this code.

Hope this be helpful

Regards

Fahad Hamsa

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Geert,

no componant usage groups or the dynamic creation of multiple component usage instances at runtime is currently not supported by Web Dynpro. You must explicitly define multiple component usages pointing to the same component or component interface definition for every runtime instance of this component which is visible on the UI.

What's your exact use case? Do you want to display Google like search result blocks which are all implemented as a SingleSearchResultUIComponent?

Regards, Bertram

Former Member
0 Kudos

Hi Bertram,

I asked myself the same question as Geert, because I was thinking about implementing a plugin pattern within an application. In order to dynamically add Web Dynpro screens of a plugin into my application I need to dynamically add component usage at runtime. Are there any plans to offer this? If so, when will it be available?

Thanks and regards,

Eric

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Eric,

I do not think that Fahad's solution is what you are asking for. Fahad just describes how to create a component instance at runtime for a component usage which was defined at design time.

You are asking for a more flexible approach: How to even create the component usages itself at runtime. This is, like mentioned before, not possible.

Back to your <b>Plugin Pattern Scenario</b>. You want to display visual plugin components in your Web Dynpro application without already knowing the plugin component implementation at designtime.

In case you must only display ony single plugin component implementation at the same time you can apply <b>Web Dynpro Component Interface Defintions</b>. They decouple the abstract definition of a Web Dynpro component's interfaces (interface views, interface controller) from the underlying implementation.

- Define a Component Interface Definition for your plugin component

- Define a component usage pointing to this component interface definition at designtime.

- Just embed this component into your component architecture as if it is a component implmentation: embed interface views, define navigation links, define interface controller usages, define context mapping relations, invoke the IExternal API of the component interface controller

- At runtime you can decide which component implementation of the plugin component interface defintion you want to instantiate

You can find more details on this approach within my new tutorial on <b>Web Dynpro Component Interface Defintions in Practice</b>. The presentation slides are allready available here: <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f07c3625-c971-2910-3a9c-ce131487f82c">Presentation - Web Dynpro Component Interface Defintions in Practice</a> The sample application based on local DCs will be availbale on SDN very soon.

Best regards, Bertram

Former Member
0 Kudos

Hi Bertram,

thats exactly what I have been looking for.

It's up and running. Espescially the information how to create an instance of the Web Dynpro Component Interface and how to retrieve the information about the <i>Deployable Object Name</i> and the <i>Deplayoable Object Part Name</i> has been very helpfull.

Thanks a lot and best regards,

Eric