cancel
Showing results for 
Search instead for 
Did you mean: 

close a pop-up window

Former Member
0 Kudos

Hi,

I get this message when I try to close a pop-up window:

com.sap.tc.webdynpro.services.exceptions.InvalidUrlRuntimeException: Invalid URL=javascript:self.parent.close();

I'm using NW2004s and guessed this should work.

I created an exit plug and I call it like this:

  //@@begin javadoc:close()
  /** Declared method. */
  //@@end
  public void close( )
  {
    //@@begin close()
	wdThis.wdGetAanvraagBetFiaIniInterfaceViewController().wdFirePlugExitOut(
		"javascript:self.parent.close();"
	);
    //@@end
  }

Can anyone enlighten me? Tia.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Wouter,

How are you creating the pop-up?

A simple way:

IWDWindowInfo windowInfo =(IWDWindowInfo) wdComponentAPI.getComponentInfo().findInWindows(

<b>"MyWindowName"</b>);

// create the Window

IWDWindow window = wdComponentAPI.getWindowManager().createWindow(windowInfo, true);

window.setWindowPosition(WDWindowPos.CENTER);

window.setTitle(<b>"WindowTitle"</b>);

// Save WindowInstance in Context

wdContext.currentContextElement.set<b>WindowInstance</b>(window);

// and show the window

window.open();

In the Pop-up window, when you want to close the window you only need to get the current instance and close it.

IWDWindow window =

wdContext.currentContextElement().getWindowSearchInstance();

window.close();

window.destroy();

Of course you'll need to create an attribute in the context of type IWDWINDOW (called WindowInstance for example)

for keep the window intance. And it should be mappend in the 2 views where you want to use it.

Hope it helps

Answers (3)

Answers (3)

Former Member
0 Kudos

Tnx. Worked, we built it into our utils.

Former Member
0 Kudos

Hi,

Create a html file say close.html with the following code and place it under srcmimesComponents<Component package>close.html

<html>

<head>

<script langauage="javascript">

function closeWindow()

{

var currWindow = window.top;

currWindow.opener = window.top;

currWindow.close();

}

</script>

</head>

<body onload="javascript:closeWindow()">

</body>

</html>

In you action,

public void close( )

{

//@@begin close()

String Url = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getComponent().getDeployableObjectPart(),"close.html");

wdThis.wdGetAanvraagBetFiaIniInterfaceViewController().wdFirePlugExitOut(Url);

//@@end

}

For other pop ups and dialog refer to the following tutorial

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#23">Dialog boxes in webdynpro</a>

Former Member
0 Kudos

Hi Wouter,

You must have created window Instance to show popup.

Store this window instance in the context.

Now, when you click close on popup window, call one method of component controller.

In component controller, create one event and in view create a event hndler and specify event created in component controller.

Now, you can write following to close or destroy your window:

IWDWindow window =

wdContext.currentContextElement().getWindowInstance();

window.close();

window.destroy();

Here, WindowInstance is the context attribute where you have stored your window instance.

Regards,

Bhavik