cancel
Showing results for 
Search instead for 
Did you mean: 

How to close the pop up window ?????

Former Member
0 Kudos

Hi all,

How to close the pop up window without having its refrence and then taking control back to the parent window.Please reply in detail

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi amit,

If you know ur window name , then you can access it using following code and use distryinstance() function to destry the window. After it will get destryed the control will itself go to the window through which it had been launched.you can use following code.

IWDWindowInfo windowInfo = (IWDWindowInfo)WdComponentAPI.getComponentInfo().findInWindows("ur window name"); IWDWindow window = wdComponentAPI.getWindowManager().createModalWindow(windowInfo);

window.destroyInstance();

I think this wud have answered ur question.

thanks

reena

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Amit

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/dialog%20boxes%20in%20web%20dynpro%20applications.pdf">Try this Tutorial</a>

Regards

Chaitanya.A

former_member751941
Active Contributor
0 Kudos

Hi Amit,

Follow the steps.

Step1: Create a WD Component.

Step2: Under Component Controller create a Value Node “EmployeeInfo” with attribute “EmployeeName” and “Position” and a context attribute “WindowInstance” of type “com.sap.tc.webdynpro.services.session.api.IWDWindow”

Step3: Create 2 Views

i>EmployeeView

Layout like

-


Employee Name : EmployeeInfo.EmployeeName(InputField)

Employee Position : EmployeeInfo.Position(InputField)

DisplayResultButton

ii>DisplayView

Layout like

-


Employee Name : EmployeeInfo.EmployeeName(TextView)

Employee Position : EmployeeInfo.Position(TextView)

CloseWindowButton

Step3: Create 2 Windows

1>EmployeeWindow

2>DisplayWindow.

Under “EmployeeWindow” add the “EmployeeView”

and “DisplayWindow” add the “DisplayView”

Step3: Go to the Diagram View. Do the mapping between “EmployeeView” and “Component Controller” and between “DisplayView” and “Component Controller”

Step4: Associate action “DisplayResult” with the “DisplayResultButton” and use this code inside the Implementation of “EmployeeView”

public void wdDoInit()

{

//@@begin wdDoInit()

wdContext.nodeEmployeeInfo().addElement(wdContext.createEmployeeInfoElement());

//@@end

}

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

{

//@@begin onActionDisplayResult(ServerEvent)

IPrivateEmploeeView.IEmployeeInfoElement emp = wdContext.createEmployeeInfoElement();

emp.setEmployeeName(wdContext.currentEmployeeInfoElement().getEmployeeName());

emp.setPosition(wdContext.currentEmployeeInfoElement().getPosition());

wdContext.nodeEmployeeInfo().addElement(emp);

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

"DisplayWindow");

// create the Window

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

window.setWindowPosition(WDWindowPos.CENTER);

window.setTitle("WindowTitle");

window.setWindowSize(100,100);

// Save WindowInstance in Context

wdContext.currentContextElement().setWindowInstance(window);

// and show the window

window.show();

//wdThis.wdFirePlugInDisplay();

//@@end

}

Step5: Associate action “CloseWindow” with the “CloseWindowButton

” and use this code inside implementation of “DisplayView”

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

{

//@@begin onActionCloseWindow(ServerEvent)

IWDWindow window = wdContext.currentContextElement().getWindowInstance();

window.destroyInstance();

//@@end

}

Regards,

Mithu

former_member225041
Participant
0 Kudos

Hi Amit,

Create one context attribute of the type "com.sap.tc.webdynpro.services.session.api.IWDWindow".

The action from which you open the pop up window ,set this context attribute to the window object that you have created for your popup window.

Now,

You need to create button on the pop window say close.

And action of close button get the ,

Just write the following

IWDWindow window=wdContext.currentContextElement().getPopUpclose();

where PopUpclose-the context attribute that you have created of window type.

window.destroyInstance();

It will solve your problem.

Former Member
0 Kudos

You need the reference to the popup window. Store it in the context for example.

Then to close it just execute this:

popupInstance.destroyInstance();

The popup will be closed and the parent window will be displayed again.