cancel
Showing results for 
Search instead for 
Did you mean: 

Eventing between popup window and parent window.

former_member185029
Active Contributor
0 Kudos

Hello Xperts,

I have a requirment where I need to perform some action on the parent window as soon as the child window is closed.

The child window is the window instance opened using


window.openNonModalExternalWindow(String, String);

Where I am passing the URL of the child window application as a parameter.

Both parent window and the child window are residing in one single component.

1. How do I catch the eventing of closing the child window in my parent window?

2. How do I pass value from child window to parent window?

I tried [this |https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7143] blog but it did not work for me.

Please guide.

-Ashutosh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Ashutosh,

I think what you want to achieve is not easy to achieve with an external Window. But I think it is technically possible using portal eventing. In the document of the URL that you open you would have to insert a javascript in the body tag:

<body onbeforeunload="opener.epcm.raiseEvent(namespace,eventname,data,sourceId);"/>

In your WD application you would have to subscribe to that event. I have not tried it, but I think it is possible.

But I would encourage you to use a modal window inside your application or a different view as popup windows are not a good way of getting user input.

Kind regards

Matthias

former_member185029
Active Contributor
0 Kudos

Thanks Matthias for the reply.

Infact I had the window as modal window. But the requirement was also to be able to resize the external window. Hence I had to go for non modal external window.

-Ashutosh

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I had done this earlier, As you said, two windows are in the same component. So what you can do is just create a method in component controller and in that method you can access the parent window or what ever functionality you want to do.

Revert me if you have any doubts.

Regards

Raghu

former_member185029
Active Contributor
0 Kudos

Hi Raghu,

I have done the same in my component.

I have a method defined in component controller which I am calling from my child window.

Unfortunately the data sharing and event tracking does not happen in this case as we are actually calling 2 different instance of applications.

If you have the code sample with you, please snd me.

-Ashutosh

The same thing applies to Ritushree.

Former Member
0 Kudos

Hi,

Below is code

Code in Second View in Second Window

public void onActiontransfer(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActiontransfer(ServerEvent)

//$$begin ActionButton(2045359057)

//wdThis.wdFirePlugSecondoutbond();

//$$end

//(Transfering the data in table of second view Second window to First view first window)

//nodeFlight_List_1_1() has context mapping with Component Controller and First view

//So data will pass from second view to first view

WDCopyService.copyElements(wdContext.nodeFlight_List_1(),wdContext.nodeFlight_List_1_1());

//invalidating the nodeFlight_List_1() in Component Controller mapped with firstview

//so table in firstview will be invalidated

wdThis.wdGetExamcomponentController().wdGetContext().nodeFlight_List_1().invalidate();

//@@end

}

//Closing the window under Action. Method is written in Component Controller

public void onActionclosewindow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionclosewindow(ServerEvent)

wdThis.wdGetExamcomponentController().closewindow();

//some manupulation of data in first view through context mapping

for(int i=0;i<wdContext.nodeFlight_List().size();i++)

{

wdContext.nodeFlight_List().setSelected(i,false);

}

//@@end

}

Component Controller Code

//This is to open second window from first window

public void opensecondwindow( )

{

//@@begin opensecondwindow()

windowInfo=wdComponentAPI.getComponentInfo().findInWindows("Secondwindow");

//create window

window=wdComponentAPI.getWindowManager().createModalWindow(windowInfo);

//set size and position

window.setWindowPosition(90,30);

window.setWindowSize(200,200);

//open window

window.show();

//@@end

}

//@@begin javadoc:closewindow()

/** Declared method. */

//@@end

//This method is to close Second window called from second view/second window

public void closewindow( )

{

//@@begin closewindow()

window.destroyInstance();

//@@end

}

Hope this is clear now

Regards

Raghu

former_member185029
Active Contributor
0 Kudos

Thanks a lot Raghu,

But please read my question..I am not using modal window.

I am creating external non-modal window.

So this solution is not applicable to me

--Ashutosh

Former Member
0 Kudos

Hi Ashutosh,

You can try by using the same component controller for the child and parent view. Then place a "close" button on whose the action the component controller will be called and in this send the data to the component controller node which intern will be mapped to the parent view and there fore data will flow to the parent.

If you use same component , then child data will flow easily to parent.

Thanks

Ritushree