Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Menu.showContextMenu () throws exceptions when excluding ISC_Grids.js

    Using:
    SmartGWT LGPL 5.0-2015-01-11
    GWT 2.5
    FF 19

    I am trying to "shrink" down the SmartGWT distribution.
    For starters, I don't need grids, so I did this:

    Short version:
    I remove the include for ISC_Grids.js from my app HTML file, and I get this failure when calling Menu.showContextMenu ():
    $wnd.isc[scClassName] is undefined

    Long version:
    1. Specify no script in my gwt.xml:
    Code:
    <inherits name="com.smartgwt.SmartGwtNoScript"/>
    2. Include JS files individually:
    Code:
    <script src="portal/sc/modules/ISC_Core.js"></script>
    <script src="portal/sc/modules/ISC_Foundation.js"></script>
    <script src="portal/sc/modules/ISC_Containers.js"></script>
    <script src="portal/sc/modules/ISC_Forms.js"></script>
    <script src="portal/sc/modules/ISC_Grids.js"></script>
    <script src="portal/sc/modules/ISC_DataBinding.js"></script>
    <script src="portal/sc/skins/Graphite/load_skin.js?isc_version=9.0.js"></script>
    3. Run the app to make sure it runs fine

    4. Remove the include for ISC_Grids.js to save bandwidth, and then I get this when I right-click on an HLayout:
    Code:
    <Portal$1> <>com.google.gwt.event.shared.UmbrellaException: Exception caught: (TypeError) @com.smartgwt.client.widgets.menu.Menu::showContextMenu()([]): $wnd.isc[scClassName] is undefined
     at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
     at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:72)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:606)
     at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
     at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
     at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
     at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
     at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
     at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
     at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
     at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
     at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
     at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
     at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
     at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:606)
     at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
     at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
     at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
     at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
     at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
     at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
     at java.lang.Thread.run(Thread.java:745) Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError) @com.smartgwt.client.widgets.menu.Menu::showContextMenu()([]): $wnd.isc[scClassName] is undefined
     at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
     at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
     at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
     at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
     at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
     at com.smartgwt.client.widgets.menu.Menu.showContextMenu(Menu.java)
     at org.fileprotocol.portal.client.layout.FileLayout$2.onShowContextMenu(FileLayout.java:118)
     at com.smartgwt.client.widgets.events.ShowContextMenuEvent.dispatch(ShowContextMenuEvent.java:104)
     at com.smartgwt.client.widgets.events.ShowContextMenuEvent.dispatch(ShowContextMenuEvent.java:1)
     at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
    My code to show a context menu:
    Code:
    private Menu contextMenu;
    
        // customize the context menu
        super.addShowContextMenuHandler (new ShowContextMenuHandler () {
          public void onShowContextMenu (final ShowContextMenuEvent event) {
    
            // clear previous context menu
            if (contextMenu != null) {
              logger.error ("destroying previous menu");
              contextMenu.destroy ();
              contextMenu = null;
            }
    
            // delegate
            contextMenu = new Menu ();
            final MenuItem menuItem = new MenuItem ("HEY");
            contextMenu.addItem (menuItem);
    
            logger.error ("showing context menu");
            contextMenu.showContextMenu ();
    
            // do not show the browser context menu
            event.cancel ();
          }
        });
    This works fine when including the following in my HTML file:
    <script src="portal/sc/modules/ISC_Grids.js"></script>

    When I remove the line, my context menu fails.

    Any advice?

    #2
    Hi shortpasta,

    see the menu docs.

    Menu is a subclass of ListGrid.
    So using a menu without ISC_Grids.js will most likely not be possible.

    Best regards,
    Blama

    Comment


      #3
      HAHA!
      It didn't even occur to me to check that.
      Solved, thank you!

      Follow-up question then -- can anybody recommend a replacement menu that doesn't require the 891 KB needed by ISC_Grids.js?

      Comment

      Working...
      X