cancel
Showing results for 
Search instead for 
Did you mean: 

Invoke Parent Component from Child

Former Member
0 Kudos

I have one DC Web dynpro project with multiple web dynpro components. CompA uses CompB. CompA and CompB both have 1 views each. When I show CompB view, can I navigate to CompA using a plug or use CompA by firing an Event ?

Current attempts by me to achieve this have failed. I am thinking may be the CompA has not been initialized yet. Is there any way to initialize CompA from the child CompB?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Yes Vishwas I have 2 applications. 1 starting from parent CompA and the 2nd starting from the child CompB. When I start from the child CompB, I cannot goto CompA by anything I have tried.

Rocío, your suggestion will only work when I start from parent CompA first.

Former Member
0 Kudos

Franz:

Did you try this?:

In Component B

if( ! wdThis.wdComponentAComponentUsage().hasActiveComponent()){

wdThis.wdGetAComponentUsage().createComponent();

}

Hope it helps you.

Rocío.

0 Kudos

Faraz,

This makes sense now.

The simple reason why you cannot reach from Component B to Component A is that there is no dependency declaration in Component B for Component A. This can't be done as this will result in a cyclic dependency situation.

You may want to use WDURLGenerator API to get an URL for you application assigned to component A to navigate.

Take a look at [this blog|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/10931] [original link is broken] [original link is broken] [original link is broken];. This will be helpful.

Vishwas.

Former Member
0 Kudos

Hi Rocío,

Because CompA uses CompB and not viseversa, the code wdThis.wdComponentAComponentUsage()

cannot work in CompB.

Thanks anyways.

Former Member
0 Kudos

So the answer is Vishwas last post.

Former Member
0 Kudos

Thanks Vishwas, problem solved. Thanks to Rocio for helpful contribution.

0 Kudos

Good that I could help!

Former Member
0 Kudos

The only problem being it doesn't work when running in Portal.

Exit-Plug must no be triggered with an URL when running in portal. Use portal navigation 
instead to navigate to another application!

Former Member
0 Kudos

Hi Franz:

So if you want to run it in portal you should see this great doc:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b5380089-0c01-0010-22ae-bd9fa40d...

Hope it helps you.

Rocío.

Former Member
0 Kudos

Thanks Rocio. Very good doc.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Faraz:

I don´t know exactly you requirement but you can navigate from iviewA to iviewB and from iviewB to iviewA doing the following:

Navigation from B to A

1- Create an iviewSet in CompA and embeb ivewA and iviewB

2- Go to "Interface view" in your B Component project and open the interfaceIview. Create an outplug in interfaceview in componentB

3- Rebuilt project B and A

4- You now can see de outplug in componentB so you can add a linknavigation to an inplug in componentA

Navigation from A to B I understand you got it.

Hope it helps you.

Rocí

former_member191569
Active Participant
0 Kudos

Hi Faraz,

you can check wheter the component is initialized by logging in the lifecycle method "wdDoInit" of any controller.

For your problem, check this:

Former Member
0 Kudos

Hi David,

Yes the component is not initialized. My problem is slightly different than the thread you gave me. I don't have a problem when I start from a parent component i.e. show a view from CompA and then navigate to a view in child component CompB and back. The problem arises when I start from a view in CompB and want to navigate or fire an event in CompA.

Former Member
0 Kudos

Hi,

If you are using compA in compB then,

In compB's component controller create method say mok and an fire event ,say efireok.In method mok write,

wdThis.wdFireEventEfireok();

First assign view and controller of CompA to Interface controller.

In webdynpro explorer of CompB,you can see Used Webdynpro compnents.There add CompA .

Now if you want comp A to be open in another window,create one window in CompB and add CompA in that window.

Create one event handler on compB's view which handles fire event we created.

This way will work.

Regards

Prajakta

Former Member
0 Kudos

As I said this method only works when I start from the parent component. If I start from the child component and

want to navigate to the parent I get the exception as below,

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Cannot navigate from view 
ChildCompInterfaceView because it is not part of the current view assembly 

    at com.sap.tc.webdynpro.progmodel.view.View.navigate(View.java:538)
    at com.sap.tc.webdynpro.progmodel.view.View.navigate(View.java:462)
    at com.child.comp.wdp.InternalChildCompInterfaceView.wdFirePlugGoBack
(InternalChildCompInterfaceView.java:144)
    at com.child.comp.ChildCompView.onActiongoBack(ChildCompView.java:143)
    at com.child.comp.wdp.InternalChildCompView.wdInvokeEventHandler(InternalChildCompView.java:138)

former_member191569
Active Participant
0 Kudos

How is tit possible that the parent component has not been initialized? I suppose the parent component is the first in execution

0 Kudos

Faraz,

How do you start from a view in Comp B? Do you have two applications? It will be helpful if you post the structure of your components and their dependencies.

Vishwas.