cancel
Showing results for 
Search instead for 
Did you mean: 

Close Window (main application) in 2004s

Former Member
0 Kudos

Hi,

I have a webdynpro application (developed in 2004s) where I have a close button. When user clicks close button, I simply need to close the browser.

I tried using javascript:void(window.close())" as exit plug parameter from interface view still throws me an exception com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Invalid URL=javascript:void(window.close())

Is there any way to close the main application window.

Thanks for your time and help.

Best Regards,

Shiva

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This can close the Window from Controller, and no Logoff from portal issue.

It doesn't need to create any outbound plug.

1. Create a Close.html. and it under the

src\mimes\Components\<Component package>\close.html

<html>

<head>

<script langauage="javascript">

function closeWin(){

window.close();

}

</script>\

</head>

<body onload="javascript:closeWin();"> </body></html>

2. Use the following code.

try{

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

TaskBinder.getCurrentTask().getClient.sendRedirect(Url, 0);

}

catch (Exception e)

{

e.printStackTrace();

}

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Shiva,

Follow sridhar's reply above. it works as i mysself have tried it.

In your html use the following code.this code will not ask you before closing.

<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>

If you want you can have a confirmation dialog in your webdynpro application before closing the application main window.

Use the step 6 code in you appropriate action

need anything can reply.

Former Member
0 Kudos

Hi Shriram,

Here problem is not with the javascript coding. How to use this javascript code in webdynpro. I am going to mention the issues again.

If this javascript code is in exit.html file. we need to navigate to this file once we click the close button. To achieve that we need to

create a Resource Url using below code

WDURLGenerator.getWebResourceURL(wdComponentAPI.getDeployableObjectPart(),"exit.html") once we create that below are the issues:

1) In NW 2004s portal won't support FirePlugs with Url. We need to use WDPortalNavigation.navigateAbsolute() method for navigation.

2) In WDPortalNavigation.navigateAbsolute() we need to pass PCD Url. But here it is Resource url.

Then how can we navigate to html file.

Thanks

Sreekanth

Sigiswald
Contributor
0 Kudos

Hi Sreekanth,

Maybe you can try the javascript/IFrame solution I described here:

Kind regards,

Sigiswald

Former Member
0 Kudos

HI

METHOD 1

1) In your Interface view, create an exit plug with a parameter Url of type string.

2) Add your Interface view controller to your current view's required controller. (in properties tab of your view)

3) After opening the new External window fire the outbound plug as :

wdThis.wdGet<your interface view controller>().wdFirePlug<your exit plug's name>("javascript:void(window.close())");

METHOD 2

1)WDClientUser.forceLogoffClientUser(url);

(url here cane be blank html page which closes itself onLoad or any other webpage you want )

for eg. WDClientUser.forceLogoffClientUser(close.html);

or WDClientUser.forceLogoffClientUser(www.sn.sap.com); etc

Former Member
0 Kudos

Hi Virag,

If you see my post I am using Method 1 only. This is not working(FirePlug in portal) in 2004s. I already tried Method 2 also, but failed.

Thanks

Sreekanth

Former Member
0 Kudos

Hi Shiva,

I also have similar req. Did you find any solution for this. If so please post that.

Thank you,

Sreekanth

Former Member
0 Kudos

Hi Shiva,

Go through thread.

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

Thanks for the reply but I have gone through the thread before posting. I'm using 2004s and the code given doesn't work.

Is there any other way to close window?

Thanks for your time and help.

Thanks & Regards,

Shiva

Former Member
0 Kudos

Hi,

Have you tried creating a static html page with the javascript to close the window? Then you can fire an exit plug to this html page.

You can also try the following code:


//TaskBinder is of type com.sap.tc.webdynpro.services.task.TaskBinder
TaskBinder.getCurrentTask().getClient().sendRedirect("javascript:window.close();",0);

Here I would like to point out that, it looks to me that TaskBinder may not be a part of the standard WD API. So in later versions this may not be supported.

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

I tried your code, but I get a Invalid Url exception.

Did you try your code. Can you tell me why I get this exception.

Thanks in advance,

Marinus

sridhar_k2
Active Contributor
0 Kudos

Hi,

Go thru the below steps. Here u need to create a html file to close the main window.

1. In your component's interface view, create an exit plug. Name it as - ExitPlug It types as "Exit".

2. Create a paramater for this exit plug. Name this parameter "Url". It should be exactly like the same name.

3. In your view add the interface view as a required controller.

4. Create your HTML file. Let's say you call it Static.html.

<html>
<head>
<script langauage="javascript">
function closeWin(){				window.close();	
}
</script>
</head>
<body onload="javascript:closeWin();">	</body></html>

5. Save this in the mimes folder for your DC under your package. You do this from the navigator view.

6. Now use the following code:

try {String url = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getComponent().getDeployableObjectPart(),"Static.html");wdThis.wdGet<your component name>InterfaceViewController().wdFirePlugExitPlug(url);} catch (WDURLException e) {}