Exception with popupmenues that are stored in a global

Hello,

when I store a popupmenu in a global, because I only want to create the popupmenu once per session, I now get a class cast exception in Servoy 3.5.3 as soon as I ‘reuse’ the stored popupmenu. In Servoy 3.1.x there was no problem.

This is an example,

var vMenuArray,
    vMenuSub;

vMenuArray = new Array();
vMenuSub   = new Array();

// create popupmenu
vMenuSub[0] = plugins.popupmenu.createMenuItem('Item1', myMethod );

// store popupmenu in a global
globals.popupmenu = vMenuSub;


vMenuArray[0] = plugins.popupmenu.createMenuItem('Item 1 ...', globals.popupmenu);
vMenuArray[0] = null;
vMenuArray[0] = plugins.popupmenu.createMenuItem('Item 1 ...', globals.popupmenu);

// => after last step the following error occurs:
// org.mozilla.javascript.JavaScriptException: java.lang.ClassCastException: javax.swing.JPopupMenu

Could you please fix this.

Thank you.

Christoph

There are two threads about this currently. See here

http://forum.servoy.com/viewtopic.php?t=9052