cancel
Showing results for 
Search instead for 
Did you mean: 

Component usage and creating popup windows dynamically

Steven_UM
Contributor
0 Kudos

Hi folks,

I have created a webdynpro component A which has 2 windows.

Window 1 has somewhere code in a view to call window 2 as a popup window.

It works all fine when just testing the component.

Now I have another component B which is basically the main menu of the application - in that menu I have 2 links which should show window 1 and window 2 of the same component A. Works fine.

But my popup window doesn't work anymore ... Well it doesn't work when I allready showed the referenced window via the second link.

Looking at the "createWindow" method it says that " ... a creation of a new instance of a windowInfo is only possible, if it doesn't exist any other window instance with the same windowInfo (including interface views, which are embedded in other component instances). ".

So I changed my referencing model from "createondemand" into "manual" and

used the following code with the idea that I created 2 different instances of the same component and that I would be fine ( added the delete part later on as only creating didn't work 😞

if (wdThis.wdMyComponentUsage().hasActiveComponent())

{

wdThis.wdMyComponentUsage().deleteComponent();

}

wdThis.wdMyComponentUsage.createComponent();

But doesn't work either ... I think I am not completely clear on the idea here ...

Basically I want 2 independant instances of the same component and I don't want them interfering on window usage ... so I can happily open my popup window ...

Is that possible ? According to the help I am not able to open the window as it is allready opened somewhere else - great - but I deleted the component first so I would think that would remove the window usage as well ???

Thanks,

Steven

Accepted Solutions (0)

Answers (3)

Answers (3)

Steven_UM
Contributor
0 Kudos

Hi Folks,

In the meanwhile I solved this issue in the most badly way ... I created a new window and attached a copy of my view to that window et voila ... it works ...

The whole idea was to avoid this kind of duplicate coding and UI but apparently the webdynpro framework is forcing me in doing so ...

I would be more then happy if somebody would point me out that I missed something conceptually ...

To recap, basically I open a DC from 2 different locations in a web dynpro application and open the same window twice - once as a normal and once as a popup - this only works properly as long as the window hasn't been opened allready as a normal one ... Although I deliberately create the component instantiation manually and have put in delete code ( which is getting executed as I debugged it ), the window instance remains 'active' (while not even visible anymore ) and as such prevents it from getting openend in the popup ... I would have thought that the whole idea of using DC is reusability but apparently that doesn't work out for window instances ...

Steven

Former Member
0 Kudos

Hi Steven,

Are you destroying the window instance before opening the window for second time ?

Regards, Anilkumar

Steven_UM
Contributor
0 Kudos

Hi Anilkumar,

I would have hoped that the framework takes care of that ... I didn't find any method that would allow me to destroy the window instance.

Just for the sake of clarity - the steps

(1) Menu link 1 is clicked which creates instance of DC, fires plug A - this results in window A being displayed

(2) Menu link 2 is clicked, DC instance is destroyed, DC instance is created again, fires plug B - this results in window B being displayed

( Please note that window A is not visible anymore and as such I would assume it is destroyed (as the component instance is deleted as well ))

(3) On window B, a button is clicked which opens window A as a popup

This doesn't work as apparently somehow window A is still "alive" and as such it cannot be viewed again ...

If I reverse the situation and first open window B then the popup with window A works fine, closing popup window, showing window A by clicking on link A works ...

Regards,

Steven

Former Member
0 Kudos

Hi Steven,

I think when you destroying the DC and re creating then ideally framework should take care of.I am not sure !!

You can check the thread for destroying the window

https://forums.sdn.sap.com/click.jspa?searchID=393413&messageID=2178855

Regards, Anilkumar

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Steven,

you are right; the Web Dynpro Runtime should take care of destroying popup window instances when destroying the embedding component instance. There might be a bug in the Web Dynpro Runtime which brakes this contract. I forwarded this issue within the Web Dynpro Java development team. Nevertheless you should open a CSS message please.

As a workaround you can explicitly destroy the instance of popup window A programmatically. <i>"I didn't find any method that would allow me to destroy the window instance"</i> Why not? After having created a window instance with IWDWindowManager.createWindow() you can explicitly destroy this instance of type IWDWindow via IWDWindow.destroy(). This can be triggered via serverside eventing or public method call when selecting a certain window in the master component.

Regards, Bertram

Steven_UM
Contributor
0 Kudos

Hi Bertram,

Thanks for passing this further on ... I will also create a CSS message.

It's actually not the popup window I need to destroy programmatically - that is working fine allready ( using the destroy method ) ...

I need to destroy the non-popup window instance - the one which I didn't create myself programmatically - it is created by firing the plug which starts the default plug of the embedded component window instance.

I first opened the window normally, then when the other menu link is clicked I destroy the component and at that moment I would hoped the window instance was destroyed ( but it isn't apparently )so I need to kill it myself at that point ...

Looking at the availble methods I can't find anything suitable ...

Further on the popup gets created, shown and destroyed fine ...

Like allready stated, the popup only gets created properly when the contained window hasn't been shown first via the other linkage ...

Regards,

Steven

Steven_UM
Contributor
0 Kudos

Thanks for the reply but I am allready destroying the window like you mentioned.

The problem is that it is not even getting opened when the window has been shown first via the other main menu link.

And although I destroy the component usage - the window instance is apparently still somehow 'active' ( although its not even visible anymore ).

Any other experts got any insights on this ????

Thanks,

Steven

monalisa_biswal
Contributor
0 Kudos

After closing the window u have to destroy the window's instance.

Store reference of window in a context value attribute or static variable.

<WindowrefVariable> =

wdComponentAPI.getWindowManager().createModalWindow(

wdComponentAPI.getComponentInfo().findInWindows(winname));

Destroy the window reference after closing the window.

<WindowrefVariable>.destroy();