In my application, I need to embed components dynamically (that is, the component which gets embedded is determined at runtime). I have seen the tutorial example on embedding, but there the component which gets embedded is known at design-time, whereas in my case it is not.
I figure that all components need to share a common component interface (please correct me, if I'm wrong with that). Problem is now, how can I insert the component view into the viewset dynamically? Is there something like an IWDViewset interface, and how can it be retrieved?
I never tried such a stunt myself, but I would guess that it works (roughly) in the following way:
The component interface also defines so-called "Interface Views", which are a kind of wrapper for so-called "Windows" of your component. Windows in turn are the hook that holds the whole view composition/assembly.
Define at least one interface view in your component interface and make every component implementation "implement" that interface view. (Not sure how this works, I would have to try myself).
Declare in your using component that you embed that interface view of your component interface, just like you would embed any other view. You need to declare a usage of this interface in your view first; that is done in the "Properties" tab of the embedding view, hidden as "Required Controllers". (Of course you need to declare the usage of the component interface also.)
In your code, use IWDComponentUsage.createComponent(String componentName, String deployableObjectName) to dynamically create an instance of the desired implementation.
Theoretically, that should be all that is needed. (At least, I hope so.)