cancel
Showing results for 
Search instead for 
Did you mean: 

Closing Popup window

Former Member
0 Kudos

Hi,

I've popup window but I'm not able to close this window. I've one button named "Close" so whenever i click on that button the popup window should get close.... for that i've used window.destroy, window.close, window. destroyinstance but none of them worked.

Even i've created seperate attribute named "closepopup"(com.sap.tc.webdynpro.services.session.api.IWDWindow) and tried but again stuk to the same problem.

Many times when I clik on the Close button it does nothing or it gives me null pointer exception.

The code....

IWDWindowInfo windowInfo = wdComponentAPI.getComponentInfo().findInWindows("T_Number_Window");

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

window.close();

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think here:

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

You are not closing the window instance u previously created, but a new one you are creating on the first line.

In order to open it properly, you should create it and save its instance so you can close it later. i.e.

To Open it


IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI	.getComponentInfo().findInWindows("PopupWindow");

//Create Popup window	
IWDWindow window = wdComponentAPI.getWindowManager().createWindow( windowInfo, true);
	
//Set window position on screen (pixels)
window.setWindowPosition(300, 150);
	
//Show it
window.open();

//Save window instance on context
wdContext.currentMyPopUpElement().setMyWindowInstance(window);
//Note im saving the instance of the window i just created, creating another one in order to try to close this one wont work

To close it


//Use the same instance previously saved on context
//Get popup instance and close it
IWDWindow window = wdContext.currentPopUpElement().getMyWindowInstance();
window.destroy();

Regards.

Julio C. Herrera

Answers (3)

Answers (3)

Former Member
0 Kudos

HI

First Create a context of Java type IWDWindow in both views and map the context.


To Open Window
*****************

IWDWindowInfo info = wdComponentAPI.getComponentInfo().findInWindows("Popup");
    IWDWindow wind = wdComponentAPI.getWindowManager().createModalWindow(info);
    wind.setTitle("Value Help Window");
    wind.setWindowPosition(150,150);
    wind.setWindowSize(150,150);

    wdContext.currentContextElement().setValueHelpWindow( wind);

    wind.show();
********************************************************************
To Close Window
****************

IWDWindow windwow = (IWDWindow)wdContext.currentContextElement().getValueHelpWindow();
	windwow.destroyInstance();

Mandeep Virk

Former Member
0 Kudos

hi

you implement close button functionality in componentcontroller.

IWDWindow popupwindow=wdContext.current<nodename>Element.get<Attributename>();

popupwindow.hide();

popupwindow.destryinstance();

call this method from popupwindow.

onActionClose(...)

{

wdThis.wdGet<compnentcontroller>.<methodname>();

}

Regards

sowmya.

Greg_Austin
Active Participant
0 Kudos

Are you passing the IWDWindow instance you create to the popup view in the context? This is the easiest way to close a popup. window.close() will do the trick if you are calling it on the correct instance.

-Greg

Former Member
0 Kudos

ya like u said I'm passing the iwdWindow instance to create popup window. Even I've tried the window.close. But it's not working.... Please help........

Greg_Austin
Active Participant
0 Kudos

Are you sure your button is linked to your action properly? If so I'm stuck. I've done this in many applications and never had a problem.