cancel
Showing results for 
Search instead for 
Did you mean: 

Window closing

Former Member
0 Kudos

Hi,

I have a popup window , in which i have a view. There is a "Close" button in the view. on Click of the button i need to close the window. How to achive this?

My code to create the window goes like this

<i>IWDWindowInfo windowInfo =(IWDWindowInfo) wdComponentAPI.getComponentInfo().findInWindows("Popup");

IWDWindow window = wdThis.wdGetAPI().getComponent().getWindowManager().createWindow(windowInfo, true);

window.setWindowPosition(WDWindowPos.CENTER);

window.setWindowSize(400, 300);

window.open();</i>

on action of close button i wrote

<i>IWDWindowInfo windowInfo =(IWDWindowInfo) wdComponentAPI.getComponentInfo().findInWindows("Popup");

IWDWindow window = wdThis.wdGetAPI().getComponent().getWindowManager().createWindow(windowInfo, true);

window.destroy();</i>

but it throws some error

Pls help

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Open the view.Go to Context tab

Create value attribute withname "WindowInstance" and set the type as IWDwindowInfo.

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Former Member
0 Kudos

Hi,

On your view from where you are creating Window instance, go to the Context tab. There create one value attribute with some name- window and then from the property tab, assign type as "IWDWindow".

For assigning this type, click on the button next to the property type, there choose radio button "Java Native type" and from there browse for IWDWindow type.

Let me know the status,

Regards,

Bhavik

Former Member
0 Kudos

Thanks for the info Bhavik and Anil. I have created the conext attribute of IWDWindow type in my first view. but on click of close button of popup view, how will i access the window instance so taht i can call close(?) and destroy() methods? how should i assign the window to the context???

Pls help

Former Member
0 Kudos

Hi Suresh,

Follow these steps:

1. Make one Event in the component controller or in custome controller.Like : CloseEvent

2. Make one method in the component controller or in custome controller. Like : CloseWindow

3. Now, Fire above created event from this method using this code:

wdThis.WdFireEventCloseEvent();

4. Now, goto the view, which is showed in the popup window.

5. Here you have action event and its method for the Close button. If not then create it.

6. Now, in this action method, call the above component or custom controller's method- CloseWindow using following Code:

wdThis.<Component/Custom Controller Name>.CloseWindow();

Now, upto this point what you have done is you have fired your own envet.

Now, you have to catch/handle this event.So, for this create one Event handler in the view from where you are creating Window and showing that window.

7. Goto the methods tab in that view, and create new Event handler.

*. Goto Implementation tab, and there write following code inside this event handler method:

IWDWindow window = wdContext.currentcontextelement().get<attribute name>();

window.close();

window.distroy();

This will close your window.

Do this and let me know the status.

regards,

Bhavik

Answers (5)

Answers (5)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Sujesh,

instead of storing the popup window instance within the context and accessing it via context mapping you can also store it in a member variable of the component controller. Look at the following Popup pattern description:

<i>In NetWeaver ’04, opening and closing popups is based on the following pattern: ...

1. The component controller can store a popup window instance in a private member variable of the type IWDWindow.

2. The popup window is programmatically created using the IWDWindowManager API and opened using the IWDWindow API within the component controller code.

3. The popup window is destroyed within an action event handler of a related view controller.

4. To close the popup window within the view controller, the public method closePopup() exposed by the component controller is called.

5. Within the component controller method closePopup(), the popup window instance is destroyed using the IWDWindow API.

This is a purely programmatic approach (except the declaration of the popup window itself), which goes without contexts and context mapping.</i>

Regards, Bertram

Former Member
0 Kudos

Currently, it's not possible to close a popup window like that.

But if you are developing in EP. you can create an portal Iview which is a portalComponent, whatever a JSP file or servlet, the page shoud contains the code below:

<script>EPCM.subscribeEvent(\"namespace\",\"close\",myhandler);

function myhandler(eventData){window.close();}</script>

then in your web dynpro

in the close action you should add these codes:

WDPortalEventing.fire("namespace", "close", "");

after that, you should combine these 2 iviews in one page. the page contains javascript should be invisible.

so you can use

WDPortalNavigation.navigateAbsolute(

pcd,

WDPortalNavigationMode.SHOW_EXTERNAL,

windowFeature,

(String) null,

WDPortalNavigationHistoryMode.NO_DUPLICATIONS,

(String) null,

(String) null,

parameter);

to open the popup window which contains these 2 iviews

the pcd should be the pcd url of combined page

hope it helpful

Former Member
0 Kudos

Hi Sujesh,

Here, you have created "window" instance for showing new window.

And then you have created another(seperate) instance of the same window and trying to destroy this instance.

But yor first instance of the window, which you have created before is still alive.So, you need to destroy that instance only.

For that do one thing.

Make one context attribute and set its type to IWDWindow.

then at the time of creating the instance of the window store that instance in this context.

Now, at the time of destroying window, retrieve this window instance from this context attribute and destroy using its destroy() method.

Let me know the status.

Regards,

Bhavik

Former Member
0 Kudos

Hi,

Bhavik is right.. Instead of destroyin that window instance u r creating another and destroying it .

The simplest way to handle it is to declare the IWDWindow object in the //@begintothers part of the code.This will make it global.

The u can use window.close()..and then window.destroy()...

Regards

Bharathwaj

Former Member
0 Kudos

Thanks for the info..

how will i make a context attribute? pls tell me..is it done in code level or using modelling tool..

Pls help

Former Member
0 Kudos

Please check this

Regards, Anilkumar

Former Member
0 Kudos

hi

Set the instance that you get while creating the window to a context variable. And always destroy the window instance you have opened.

regards

vln

Former Member
0 Kudos

Can u be a l'l bit elaborate on this???

Former Member
0 Kudos

the code that u hav written for opening the window

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

is returning you a window instance namely window. set it to a context variable of type IWDwindow.

wdContext.currentContextElement().setwindowinstance(window);

create a similar variable in component controller and map it to your new window(popup)view s controller as well. In the action of the close button do a window .destroy(). However you can also do it in the controller or the parent view itself.

regards

vln

Message was edited by: Bertram Ganz

Use wdComponentAPI shortcut variable