Announcement

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

    Bug after filtering on onCellHover

    I think there is a bug when combining filtering on a listgrid and an onCellHover.

    The minimal code (a showcase example):

    Code:
    package zedes2.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.fields.DataSourceBooleanField;
    import com.smartgwt.client.data.fields.DataSourceDateField;
    import com.smartgwt.client.data.fields.DataSourceFloatField;
    import com.smartgwt.client.data.fields.DataSourceIntegerField;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.types.FieldType;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.grid.events.CellHoverEvent;
    import com.smartgwt.client.widgets.grid.events.CellHoverHandler;
    
    public class Alternate
        implements EntryPoint, CellHoverHandler
    {
    
        public void onModuleLoad()
        {
    
            final ListGrid countryGrid = new ListGrid();
            countryGrid.setWidth( 500 );
            countryGrid.setHeight( 224 );
            countryGrid.setShowAllRecords( false );
            countryGrid.setDataSource( WorldDS.getInstance() );
            countryGrid.setAutoFetchData( true );
    
            countryGrid.setCanEdit( true );
            countryGrid.setCanEdit( false );
            countryGrid.setShowFilterEditor( true );
            countryGrid.setFilterOnKeypress( true );
    
            countryGrid.setCanHover( true );
    
            // TODO: evtl nicht hier?? hier ist ja nur ein ListGrid
            countryGrid.addCellHoverHandler( this );
    
            countryGrid.setHoverWidth( 50 );
            countryGrid.setFetchDelay( 500 );
            countryGrid.setDataPageSize( 20 );
            countryGrid.draw();
        }
    
        private static class WorldDS
            extends DataSource
        {
            // The DataSource would normally be defined external to any classes that use it.
    
            private static WorldDS instance = null;
    
            public static WorldDS getInstance()
            {
                if ( instance == null )
                {
                    instance = new WorldDS( "worldDS" );
                }
                return instance;
            }
    
            public WorldDS( String id )
            {
                setID(id);  
                setRecordXPath("/List/country");  
                DataSourceIntegerField pkField = new DataSourceIntegerField("pk");  
                pkField.setHidden(true);  
                pkField.setPrimaryKey(true);  
          
                DataSourceTextField countryCodeField = new DataSourceTextField("countryCode", "Code");  
                countryCodeField.setRequired(true);  
          
                DataSourceTextField countryNameField = new DataSourceTextField("countryName", "Country");  
                countryNameField.setRequired(true);  
          
                DataSourceTextField capitalField = new DataSourceTextField("capital", "Capital");  
                DataSourceTextField governmentField = new DataSourceTextField("government", "Government", 500);  
          
                DataSourceBooleanField memberG8Field = new DataSourceBooleanField("member_g8", "G8");  
          
                DataSourceTextField continentField = new DataSourceTextField("continent", "Continent");  
                continentField.setValueMap("Europe", "Asia", "North America", "Australia/Oceania", "South America", "Africa");  
          
                DataSourceDateField independenceField = new DataSourceDateField("independence", "Nationhood");  
                DataSourceFloatField areaField = new DataSourceFloatField("area", "Area (kmē)");  
                DataSourceIntegerField populationField = new DataSourceIntegerField("population", "Population");  
                DataSourceFloatField gdpField = new DataSourceFloatField("gdp", "GDP ($M)");  
                  
                setFields(pkField, countryCodeField, countryNameField, capitalField, governmentField,  
                        memberG8Field, continentField, independenceField, areaField, populationField,  
                        gdpField);  
          
                setDataURL("ds/world.data.xml");  
                setClientOnly(true);  
                
            }
    
        }
    
        @Override
        public void onCellHover( CellHoverEvent event )
        {
            ListGridRecord lg = event.getRecord();
            System.out.println( lg.getAttribute( "countryName" ) );
        }
    
    }
    If I change the continent filter (the selectItem) and QUICKLY move to a record, so that onCellHover is called before the filtering actually occurs, I get this exception:

    Code:
    Uncaught JavaScript exception [TypeError: _1 is null] in http://127.0.0.1:8888/zedes2/sc/modules/ISC_Core.js, line 3366
    
    
    com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
        at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        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:213)
        at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord
        at com.smartgwt.client.widgets.grid.events.GridRowColEvent.getRecord(GridRowColEvent.java)
        at zedes2.client.Alternate.onCellHover(Alternate.java:104)
        at com.smartgwt.client.widgets.grid.events.CellHoverEvent.dispatch(CellHoverEvent.java:100)
        at com.smartgwt.client.widgets.grid.events.CellHoverEvent.dispatch(CellHoverEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        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:213)
        at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Unknown Source)
    Code:
    18:30:58.324 [ERROR] [zedes2] 18:30:58.256:IFCS4:WARN:Log:TypeError: _1 is null
    Stack from error.stack:
        unnamed(isc_Canvas__getHoverPropertie) @ zedes2/sc/modules/ISC_Core.js:3366
        unnamed(isc_GridRenderer__showHove) @ zedes2/sc/modules/ISC_Grids.js:830
        unnamed(isc_GridRenderer__cellHove) @ zedes2/sc/modules/ISC_Grids.js:829
        unnamed(isc_c_Hover__doActio) @ zedes2/sc/modules/ISC_Core.js:4309
        unnamed(isc_c_Class_fireCallbac) @ zedes2/sc/modules/ISC_Core.js:339
        unnamed(isc_c_Timer__fireTimeou) @ zedes2/sc/modules/ISC_Core.js:1440
        unnamed() @ zedes2/sc/modules/ISC_Core.js:1435
        unnamed() @ 
    com.smartgwt.client.core.JsObject$SGWT_WARN: 18:30:58.256:IFCS4:WARN:Log:TypeError: _1 is null
    Stack from error.stack:
        unnamed(isc_Canvas__getHoverPropertie) @ zedes2/sc/modules/ISC_Core.js:3366
        unnamed(isc_GridRenderer__showHove) @ zedes2/sc/modules/ISC_Grids.js:830
        unnamed(isc_GridRenderer__cellHove) @ zedes2/sc/modules/ISC_Grids.js:829
        unnamed(isc_c_Hover__doActio) @ zedes2/sc/modules/ISC_Core.js:4309
        unnamed(isc_c_Class_fireCallbac) @ zedes2/sc/modules/ISC_Core.js:339
        unnamed(isc_c_Timer__fireTimeou) @ zedes2/sc/modules/ISC_Core.js:1440
        unnamed() @ zedes2/sc/modules/ISC_Core.js:1435
        unnamed() @ 
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        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:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Unknown Source)
    The error occurs on event.getRecord(), so I think it is already null (because of the filter change) but it stills try to evaluate.
    That's why this occurs:
    java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord
    at com.smartgwt.client.widgets.grid.events.GridRowColEvent.getRecord(GridRowColEvent.java)
    at zedes2.client.Alternate.onCellHover(Alternate.java:104)

    (on the stack)

    Using SNAPSHOT_v8.3d_2012-07-30/EVAL Deployment, but I also observerd this on 3.0p EE.

    #2
    Someone ? I posted a minimal example from the showcase as required.
    Is this a bug / is there a workaround?

    Comment


      #3
      Doesn't seem to be important

      Comment


        #4
        Can someone please tell me why I don't get ANY reaction to my post?
        Isomorphic?

        Comment


          #5
          You can resolve this issue by adding a null-check to your cell-hover method:

          Code:
              @Override
              public void onCellHover( CellHoverEvent event )
              {
                  ListGridRecord lg = event.getRecord();
                  if (lg == null) {
                      System.out.println(" *** NULL ***");
                      return;
                  }
                  System.out.println( lg.getAttribute( "countryName" ) );
              }

          We are making a change to the framework to avoid the cellHover handler from firing at all with a null record. This will be present in nightly builds going forward in the 3.1d branch

          Regards
          Isomorphic Software

          Comment

          Working...
          X