VMware {code} Community
rutvijdhotey
Contributor
Contributor

WEB_PLATFORM loses reference and goes to null after Dialog Box Closes in a subplugin.

Problem:

Opening a page in my plugin on Vcenter Vsphere WebClient with images and CSS and JS file associated. In the JS i have a method which opens up a Modal Dialog box on a click action. When i close the modal dialog, the icons and images on the original page get bigger, and also some css is lost on some other elements. I also cannot find the JS file associated with the page.

When i tried debugging it, i set breakpoints before and after closing the Dialog box. It turns out that WEB_PLATFORM loses its reference after the dialog box is closed. It turns out to be null.

Solutions Tried:

I tried saving the WEB_PLATFORM and using it after closing but that doesnt work. I also tried a shallowcopy of the same and using it later but that doesnt work either.

Note: The problem persists only on IE and Chrome. Mozilla Firefox works perfectly as it is supposed to.

Any help would be great.

Thank you.

Reply
0 Kudos
6 Replies
laurentsd
VMware Employee
VMware Employee

I just replied to the same question last week, see Vsphere Web Client Modal Dialog open for Plugin Issue in Chrome and IE

Thanks.

Reply
0 Kudos
rutvijdhotey
Contributor
Contributor

Thank you so much for your reply Laurent.

I read through it and I tried saving the 4 fields you stated namely, ObjectId, ActionId, ActionTargets and Locale. I also tried creating an HTMLObjectElement and saving back these fields in that object. But that didnt work either.

In my code:

I have a close button and when i click that button i close that Open Modal Dialog. I tried saving that WEB_PLATFORM reference using a shallow copy, recreating an HTMLObjectElement but both these didnt work and i lost the WEB_PLATFORM ,when i closed the dialog and returned to my plugin page.

Please let me know if there are any other solutions i could try.

Thank you,

Rutvij Dhotey.

Reply
0 Kudos
laurentsd
VMware Employee
VMware Employee

It's hard to provide more help without seeing your code.  Can you attach it or modify an existing HTML SDK sample to reproduce the problem?

Reply
0 Kudos
rutvijdhotey
Contributor
Contributor

HI Laurent,

Sorry to get back to you late.

I am attaching code so that you have an idea of what I am trying to do.

I will also add a step by step guide of what actions i am performing so that you can understand the output.

Steps:

1. When i enter the plugin from vSphere i have a table with certain entries in it.

2. I have a written code so as to open up the details of that entry in a certain modal after i select the table entry.

The code for the same is :

$('SOME TABLE')

                            .click(

                                    function() {

                                        if (SOME LOGIC) {

                                            var url = "THIS URL IS THE LINK TO THE HTML DOCUMENT THAT IS GOING TO OPEN IN THE MODAL, lets say modal.html";

                                            WEB_PLATFORM

                                                    .openModalDialog(

                                                            ns

                                                                    .getString("SOME PROPERTIES STRING"),

                                                            url,

                                                            500,

                                                            550,

                                                            ENTRYid

                                                                    + ":"

                                                                    + vcenterServiceGuid);

                                        }

                                    });

After this step the modal opens up perfectly and i see it pop up on the screen with icons & buttons to close the same using this code:

This code is in the JS file for the Modal dialog and not the main screen from where we are opening the modal Dialog.

$("#closeButton").on('click', function() {

    var temp = WEB_PLATFORM;

    WEB_PLATFORM.closeDialog();

    WEB_PLATFORM = temp;

  });

I tried saving the WEB_PLATFORM reference but apparently this doesnt work, after the modal dialog is closed and i return to the original table page, all the css and JS files are broken and the WEB_PLATFORM loses the reference.

P.S. This happens only in Ie and chrome.

Please let me know if you need any other details and i will provide the same.

Reply
0 Kudos
laurentsd
VMware Employee
VMware Employee

There is a known problem with WEB_PLATFORM in SDK 6.5 if you open a modal dialog.  You can either cache values that are returned by WEB_PLATFORM APIs before you open that dialog, or if the modal is not very big the best is to make it local to your plugin view, i.e. use a Javascript modal directly instead of using the API openModalDialog.

Reply
0 Kudos
_vladi_
VMware Employee
VMware Employee

If your plugin will need to work only on the HTML Client please watch out for future Fling releases where this use case will be better supported.

Cheers,

Vladi

Reply
0 Kudos