cancel
Showing results for 
Search instead for 
Did you mean: 

External Context Mapping - Pass data from Child to Parent

Former Member
0 Kudos

Hello,

I have the following scenario:

DCParent Component (contains)

- DCChildComp1 (used DC)

- DCChildComp2 (used DC)

- DCChildComp3 (used DC)

- DCChildComp4 (used DC)

What user enters in DCChildComp1 then needs to be made available to DCParent and all other DCChildComp(n) siblings.

I have looked the posts and blogs in SDN and all of them seem to deal with passing inputField data from Parent to Child. May be I am missing it.

In my case, I need the data to be passed from DCChildComp1 to DCParent ie Child to Parent. Then from DCParent to other DCChildComps.

How should I go about

a. defining the context nodes and Component Interface context nodes in parent vs child vs siblings and

b. how should I map them externally?

Step by step instruction would be helpful.

Thanks in advance,

SK.

Accepted Solutions (1)

Accepted Solutions (1)

sureshmandalapu6
Active Contributor
0 Kudos

HI

It has been discussed discussed already

refer the link

Thanks

Suresh

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks for all the help. As I had already seen all the links and blogs you had linked here, I was still confused about how it all came together. Finally, I got it after reading Bertram Ganz's response in this thread [;.

when you map a context in the parent comp to an interface context in the used child component you do not define an external context mapping relation. That's normal context mapping as the data context resides in the child component.

I have it working now and I am able to push the changes in the child component's context to the parent.

For those who are interested in how I did it (and those who know a better way to do it

In the child component DC:

Map Child's View Context to Child's Controller Context

Map Child's Controller Context to Child's Interface Controller (make sure the inputEnabled is FALSE - as the child is the data producer and the parent is the data consumer, in my case)

In the parent DC:

Add child DC as a Used DC

Add child Component as a Used Component in the Parent Component

Add Child's Interface Controller as Required Controller in Parent Component

Map Child's Interface Controller Context to Parent's Controller Context

Map Parent's Controller Context to Parent's View Context

No external mapping required per the thread above. Now, any change in the child component's view is visible in the parent component view.

Thanks again very much for the help.

- Siva

sureshmandalapu6
Active Contributor
former_member201361
Active Contributor
0 Kudos

hi ,

for external Context mapping please go through this blog

[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8881] [original link is broken] [original link is broken] [original link is broken];

Thanks and Regards

vmadhuvarshi_
Contributor
0 Kudos

Siva,

To share data from a Child Component to a Parent component, best way is to do so by means of server side eventing.

Create an event in interface controller of child component with parameters mapped to data that needs to be passed to parent component, declare usage of the child interface controller in child Component Controller. Create a Method in component controller to fire the event declared in Interface controller. After this you should be able to call this method to fire the declared event from component controller when data needs to be shared with parent component.

Parent component and all other components that need to receive data should declare usage of interface controller of child component. Define a method of type 'Event Handler' in parent component and subscribe to event raised from the child component. In this method, save the data received from event in Component context.

When you need to pass the data from child component to parent component, raise the declared event and data should be available in parent component by means of event subscription.

[This tutorial|http://help.sap.com/saphelp_nw04/helpdata/en/24/243ca46e1c334f8a6f8b0792656bc7/frameset.htm] will be helpful in understanding the concept..

Hope this helps.

Vishwas.