cancel
Showing results for 
Search instead for 
Did you mean: 

Used WebDynpro Component

Former Member
0 Kudos

Hello,

In a MainDC, There are 3 components in that. they are ComponentA ComponentB & ComponentUtil.

ComponentUtil is used component of both ComponentA & ComponentB. (property: createOnDemand)

I assume that For ComponentA, one object of ComponentUtil is created & used. And For ComponentB, another object of ComponentUtil is created. But i want only one & the same object of ComponentUtil be used in both ComponentA & ComponentB at runtime. How to achive that only one object of ComponentUtil be used in all other componets which are using this?

In CompUtil,

there is a value node called StudentNode and below 2 methods

1) First method -- addElementsToStudentsNode (inputFromOtherComponent_Studentnode) : input parameter node IWDNode. This method create StudentNode elements & set the vales with that of inputparameter elemnt & then add the element to the StudentNode.

2)Another method -- dsiplaySizeOfStudentNode() : To display the size of studentNode.

Functionallty (observe steps 3, 4, 5 & 6 carefully) :

step 1: intially From ComponentA, called dsiplaySizeOfStudentNode() of ComponentUtil -- size 0 (as expected)

step 2: ComponentB, called addElementsToStudentsNode() by passing the studentNode with 5 elements.

step 3: ComponentB, called dsiplaySizeOfStudentNode() of ComponentUtil -- size 5 (as expected)

step 4: From ComponentA, called addElementsToStudentsNode() by passing the studentNode with 3 elements.

step 5: ComponentA, called dsiplaySizeOfStudentNode() of ComponentUtil -- size 3 ( I am expecting 5+3, ie total 8 elements but the node contains only 3 latest elements which are added from ComponentA. Here i want to display 8 elements both added from ComponentA & ComponentB.)

step 6: ComponentB, called dsiplaySizeOfStudentNode() of ComponentUtil -- size 5

Observations:

For ComponentA, there is one ComponentUtil object created (this contain 3 elements) & For ComponentB another ComponentUtil object is created (contains 5 elements). But I want only one object of ComponentUtil be used both in ComponentA & ComponentB. so that i can display all (total) the elements added from ComponentA & ComponentB. According to me only one object of ComponentUtil should exsit & this object should be used in all other components which useses this ComponentUtil . How can i achieve this?

Thanks

Hussain

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Hussain

If there is no references between A and B you need the third component C which will create instance of ComponentUtil and pass the instance to A and B.

1. Add the following interface method to A and B:

public setComponentUtilUsage(IWDComponentUsage compUtilUsage) {
  wdThis.wdComponentUtilUsage().enterReferencingMode(compUtilUsage);
}

2. Change usage property from createOnDemand to manual in A and B.

3. In component C create instance of ComponentUtil and pass it to A and B:

wdThis.wdComponentUtilUsage().createComponent();
IWDComponentUsage compUtilUsage = wdThis.wdComponentUtilUsage();
wdThis.wdGetAInterface().setComponentUtilUsage(compUtilUsage);
wdThis.wdGetBInterface().setComponentUtilUsage(compUtilUsage);

BR, Siarhei

Former Member
0 Kudos

Thanks....It is answered

@Siarhei: yes there is refernece between ComponentA & ComponentB. I had made necessary modifications as per my requirmnets & now its working...

BR

Hussain

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

What I can suggest is that you can define the usage as createManually. Create the instance of the ComponentUtil wherever required and then set it to an attribute the instance you created.

This attribute should be available cross components so that you can access it.

Regards,

Manoj