cancel
Showing results for 
Search instead for 
Did you mean: 

How to Close external window?

Former Member
0 Kudos

Hi Experts,

1) For one of the development requirements, I am required to open my application in

external window. For the same, I have changed the property of the iView and page to

launch the iView in an external window and not to display in content area. Now, I am

able to display the application in a new window as per the requirement.

Now, I want to close this window from a button event on the screen, but can't find a way to close it.

If anyone's having an idea over it, that will be greatly appreciated???

2) Also, in another application, I am downloading data into excel sheet and the download

opens in a new window. Once the user clicks on the option (SAVE, OPEN, CLOSE),

the blank window should close which works well in IE 7 but in IE 6 the user says the blank

window is visible and they have to close it manually.

I am using the following code for this:


excelCSVFile = new FileInputStream(f);
IWDCachedWebResource cachedWebResource = null;
if (excelCSVFile!= null)
{
cachedWebResource = WDWebResource.getWebResource
excelCSVFile, WDWebResourceType.getWebResourceType(
"xls","application/ms-excel"));
cachedWebResource.setResourceName(fileName);
}
wdContext.currentVn_XL_SheetElement().setVa_Resource(cachedWebResource.getURL());
workbook.close();

/**
 * BEGIN: Open new window: download button
 */
IWDWindow win =  wdThis.wdGetAPI().getComponent().getWindowManager().createExternalWindow
(cachedWebResource.getAbsoluteURL(),"Print Content",false);
win.setWindowSize(0,0);
win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
win.removeWindowFeature(WDWindowFeature.MENU_BAR);
win.removeWindowFeature(WDWindowFeature.TOOL_BAR);
win.removeWindowFeature(WDWindowFeature.STATUS_BAR);
win.setWindowPosition(200,200);
win.show();
/**
* END: Open new window: download button
*/

For this if I try win.destroy() or win.close() or win.hide(), after win.show

this doesn't shows the download options at all (quite obviously ).

I want to close this blank window automaticaaly once the user selects

any option for download. Is there any solution to this or am I doing something wrong?

Helpful answers will be appreciated. Thanks in advance.

Regards,

Gaurav Bhardwaj

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Gaurav

Try win.destroyInstance().

and create a new window every time when the user click download button.Don't use the closed one.

And i don't know your download window whether is an external window or inner popup.

If it's a inner popup,you can close it by this way:

1,keep the IWDWindow win as a local parameter in the parenet view.

2,in the popup view's button action,fire an event 'xxx'.

3,in the parent view, catch the event 'xxx'.in the eventhandler,close the popup window by the parament you saved IWDWindow win. win.destroyInstance().

Regards.

Steiner.

Former Member
0 Kudos

No other way found.. We are closing the window manually now.

Thanks,

Gaurav

Former Member
0 Kudos

Hi Gaurav,

This is regarding Closing a window topic in SDN Forum. Could you please let me know whether you are able to close the window now using a button.

Thanks & Best Regards

Swetha

Former Member
0 Kudos

Hi Gaurav,

Why donot you give some timedelay say of 60000 milisecs(1min). Then close the window.

win.close() or win.destroy()

This will close the window and also allow the user to take the decision to save or open the excel.

Hope this helps.

former_member197348
Active Contributor
0 Kudos

Hi Gaurav,

If the external window contains the view of the wd component then only you can close the window.

Try like this:

Create a context attribute of IWDWindow in the calling view - component - called view and map them in all controllers.

//set the context attribute  in calling view 
win.show();
wdContext.currentContextelement().setWinref(win);
/**
* END: Open new window: download button
*/

In onActionxxx event of the downlload button

// close the window
wdContext.currentContextelement().getWinref().destroyInstance();

Regards,

Siva

Former Member
0 Kudos

Create a context attribute "extWindow" of type "com.sap.tc.webdynpro.services.session.api.IWDWindow" and then set the object "win" of type "IWDWindow" as :

wdContext.currentContextElement().setExtWindow(win);

On action of the button call a action method and then destroy the instance of window in the following way :

IWDWindow win=wdContext.currentContextElement().getExtWindow();

win.destroy();

Hope this will help you.

Thanks

Ritushree

Former Member
0 Kudos