Background
[wp_ad_camp_1]
This article demonstrates how to display and close windows using Java codes in SAP Web Dynpro for Java.
Software Environment
- Windows 7 Professional SP1
- Java 2 SDK 1.4.2 for Windows 32-bit
- SAP NetWeaver Developer Studio Version 7.0.09 for Java
- SAP NetWeaver Application Server
- sap.com/SAP-JEECOR – 7.00 SP26 (1000.7.00.26.1.20120307143343)
- sap.com/SAP-JEE – 7.00 SP26 (1000.7.00.26.0.20120109175405)
The Codes
[wp_ad_camp_2]
1 2 3 4 5 6 7 | IWDWindowInfo winInfo = wdComponentAPI.getComponentInfo().findInWindows("TestWindow"); IWDWindow window = wdComponentAPI.getWindowManager().createModalWindow(winInfo); window.setTitle("Test Window"); window.setWindowPosition(WDWindowPos.CENTER); window.setWindowSize(300,100); window.show(); wdContext.currentContextElement().setVa_TestWindowObjectReference(window); |
Note that the last line saves the window object to a view controller’s context attribute named Va_TestWindowObjectReference which is of type com.sap.tc.webdynpro.services.session.api.IWDWindow type. It is typically declared in the component controller’s context so that other view controllers can access it.
In the other view controller embedded in TestWindow, place the following codes within a method tied to a button to close the displayed window.
1 2 | IWDWindow testWindow = wdContext.currentContextElement().getVa_TestWindowObjectReference(); testWindow.destroyInstance(); |
[wp_ad_camp_3]