cancel
Showing results for 
Search instead for 
Did you mean: 

External Context Mapping

Former Member
0 Kudos

Can someone help me out with this situation:

1 - I have a parent component that defines a component interface in its public part

2 - I have a number of child components that implement the interface

3 - The child components are created dynamically using the IWDComponentUsage.createComponent(componentname, dcname)

4 - The parent has a context node and 2 attributes that are mapped to a node of the same name/seup defined in the context of the interface that is implemented by the children

5 - The child components set the node and attribute values on init and are mapped to their respective interface controller's context

I am trying to implement a test component that provides a test harness and interface, that allows individual tests to be plugged in dynamically. The tests implement an interface and are loaded dynamicaly at runtime. I want each test to supply its id/display name via external context mapping so the list of active tests can be displayed before the test suite is executed.

I assumed that when I called createComponent() for one or more child components, I would automatically have one element created per component under the parent's context node. At the moment I cant see any elements under this node. Can someone explain what I am doing wrong?

Is external context mapping with loosely coupled components possible?

Also can someone explain why I would use an interface method with parameters rather than an interface method that uses a mapped context?

Cheers,

Steve

Accepted Solutions (0)

Answers (2)

Answers (2)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Steve,

why do you apply external context mapping? As far as I understand your scenario every plugged-in test components holds its own data context with id/display name context attributes. As theses contexts attributes are data attributes they are no isInputElement=true attributes. The embedding component defines a component usage relation to the test component and maps its component context to the component interface context of the embedded test component.

<i>"I assumed that when I called createComponent() for one or more child components, I would automatically have one element created per component under the parent's context node. At the moment I cant see any elements under this node. Can someone explain what I am doing wrong?</i>"

I don't understand this assumption, or, I think it is not correct. First you have to define one component usage to every potentially plugged in test component. Ok, you can allready dynamically create a component usage of same type like the statically define one with IWDComponentUsage.createComponentUsageOfSameType(String name), but then you must do all other things dynamically also: embed component interface view in view composition, define navigation links, define context mapping relations, event subscriptions etc.

There is no automatism for populating a multiple context node with node elements for all given component usages.

I agree with you, that your use case is really interesting: Plug-in an unknown number of service components at runtime using an abstract component interface definition at designtime.

Perhaps you can make the following restriction which definitely simplifies the implementation: The number of potiential service component implmentations is not bigger than 6 (for example). Then just define six separate Component Usages to the same component interface definition (with 6 different names). At runtime you can then create as many component instances as needed unless the number is less than 6.

Regards, Bertram

Former Member
0 Kudos

Hi Bertam,

Thanks for the reply!

1 - <i>why do you apply external context mapping?</i> - I thought that I could define the id/display name of each test component in a context node in the Component Interface contex and 'copy' them to the parent's component context in order to display a list of all the tests currently plugged in.

I have a mapping from the parent components's context to the Interface Controller of the Component Interface implemented by all the child components, there is no direct usage relationship to the child components.

I managed to do the mappings ok and then use IWDComponentUsage.createComponentUsageOfSameType(String name, String name) to programatically create instances of 2 child components at runtime.

Each child component sets their component context node to define the id/display name. This is mapped to the Interface Controller in each child's component interface. I also added an 'input' context node with 2 attributes that tell the child component the id of the trip/employee to test and managed to define them as input nodes and map them to the parent's component controller context.

Since the mapping from the child's context to the parent's context is made via the implemented interface, all components would have their id/display name node mapped to the same node in the parent component's context. I assumed this would result in multiple elements, one for each child component created, appearing in the parent's context?

2 - <i>you must do all other things dynamically also: embed component interface view in view composition, define navigation links, define context mapping relations, event subscriptions etc.</i> - The child test components do not have an interface of their own, and communicate errors back to the parent via their context.

3 -<i> I agree with you, that your use case is really interesting</i> - Thanks, but having come from a J2EE background the whole component idea in WebDynpro seems a bit limited without being able to work this way? Is what I am trying to do unusual?

4 - I was wondering whether it would just be easier to do all this communication between components via method calls instead? What do you think? I was trying to use this as a learning tool to understand more about what is possible with WebDynpro and the context but I'm not sure I understand how far to go before using the context becomes too problematic.

Cheers,

Steve

Former Member
0 Kudos

OK I answered some of my own questions incase anyone is interested:

1 - If you reference components via a CID using a IWDComponentUsage you cant do external context mapping, hence why you would want to use methods and parameters.

2 - To use multiple instances of child components that all implement the same CID you need to use IWDComponentUsages for each, create, and get the external interface and cast it to the CID interface controller class e.g:

IExternalIMaxTestPlugin interfaceController1 = (IExternalIMaxTestPlugin) componentUsage1.getInterfaceController();

interfaceController1.executePlugin(employeeElement.getEmployeeNumber(),GlobalConstants.INIT_TRIPNO);

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi Steve

The external context mapping you van only do for the Comp interface controller node.Suppose i have a node in a Comp A ,i want to bind it to one of the ChildComp B of A.

The Concept is useful only at the time when you dont know the target node or mapped node.(Comp B that is child not yet defined when you perform the context mapping in Comp A)

Steps

1.Map the Comp A context and interface controller context of Comp A.

in interface controller you have a node but you dont know the target node which you have to map)

2.Set the isInputElement property to true.

3.Define the child comp

4.Declare the child comp usage in parent component

5.Then perform the mapping.

Regards

Kalyan.