Announcement

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

    JavaScriptException in CubeGrid

    I use the CubeGrid with my custom data source:
    Code:
    customDataSource.setDataProtocol(DSProtocol.CLIENTCUSTOM);
    customDataSource.setDataFormat(DSDataFormat.CUSTOM);
    
    cubeGrid.setDataSource(customDataSource);
    cubeGrid.setAutoFetchData(true);
    ...
    addMemeber(cubeGrid);
    It throws a JavaSciptException:
    Code:
    com.google.gwt.core.client.JavaScriptException:
    (TypeError): _3 is undefined
     fileName: http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Analytics.js
     lineNumber: 367
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
        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.smartgwt.client.widgets.cube.CubeGrid.create(CubeGrid.java)
        at com.smartgwt.client.widgets.BaseWidget.getOrCreateJsObj(BaseWidget.java:356)
        at com.smartgwt.client.widgets.layout.Layout.addMember(Layout.java:1073)
        at com.alsyontech.alphee.gwt.cashposition.client.widget.CashPositionMainWidget.<init>(CashPositionMainWidget.java:63)
    The problem is not about the set of the facets, since I have tried with some test data with cubeGrid.setData() and it shows correctly. But when I change to my custom data source, there is no fetchData request sent.
    By the way, I use the same custom data source with a ListGrid and it works correctly: it sends automatically a fetchData request with the initial criteria; but why in the CubeGrid with autoFetchData=true, the initial fetchData request hasn't been sent?
    Thank you very much for any help.

    #2
    For any JavaScript exception, use the Developer Console to see the stack trace (see FAQ).

    If you're trying to use a CubeGrid with load on demand, you have to provide all facet values up front. It's not clear from your code whether you're doing so. For a definitive answer, put together code we can actually run and we can comment, or run the code to see the problem.

    Comment


      #3
      Thank you for the reply.
      I restart to test a simple example with a custom clientOnly data source as followings:
      Code:
      public class CashDataSource extends DataSource {
          public CashDataSource() {
              setDataProtocol(DSProtocol.CLIENTCUSTOM);
              setDataFormat(DSDataFormat.CUSTOM);
      
              setClientOnly(true);
      
              DataSourceField bankField = new DataSourceField("bank", FieldType.TEXT);
              DataSourceField currencyField = new DataSourceField("currency", FieldType.TEXT);
              DataSourceField dateField = new DataSourceField("date", FieldType.TEXT);
              DataSourceField valueField = new DataSourceField("value", FieldType.FLOAT);
              setFields(bankField, currencyField, dateField, valueField);
          }
      
          @Override
          protected Object transformRequest(final DSRequest request) {
      
              final String requestId = request.getRequestId();
              final DSResponse response = new DSResponse();
      
              final Object clientContext = request.getAttributeAsObject("clientContext");
              response.setAttribute("clientContext", clientContext);
      
              // Assume success
              response.setStatus(RPCResponse.STATUS_SUCCESS);
      
              switch (request.getOperationType()) {
      
                  case FETCH:
                      executeFetch(requestId, request, response);
                      break;
      
                  default:
                      // Operation not implemented.
                      break;
              }
      
              final Object result = request.getData();
      
              return result;
          }
      
          protected void executeFetch(String requestId, DSRequest request, DSResponse response) {
              ListGridRecord testRecord = new ListGridRecord();
              testRecord.setAttribute("bank", "BNP");
              testRecord.setAttribute("currency", "EUR");
              testRecord.setAttribute("date", "today");
              testRecord.setAttribute("value", new Double(20));
      
              Record[] records = new Record[1];
              records[0] = testRecord;
              response.setData(records);
              processResponse(requestId, response);
          }
      
      }
      And the CubeGrid is:
      Code:
      public class CashMainWidget extends VLayout {
      
          public CashMainWidget() {
              CashDataSource dataSource = new CashDataSource();
      //If you uncomment the listGrid, you can see that the dataSource works fine //with the listGrid
      //        ListGrid listGrid = new ListGrid(); 
      //        listGrid.setDataSource(dataSource);
      //        listGrid.setAutoFetchData(true);
      //        addMember(listGrid);
      
              CubeGrid cubeGrid = new CubeGrid();
      
              cubeGrid.setValueProperty("value");
      
              Facet date = new Facet("date", "Date");
              Facet currency = new Facet("currency", "Currency");
              Facet bank = new Facet("bank","Bank");
              cubeGrid.setFacets(date, currency, bank);
              cubeGrid.setColumnFacets("date");
              cubeGrid.setRowFacets("bank", "currency");
      
      //If I use setData instead of setDataSource, the cubeGrid can be drawn correctly
       //ListGridRecord testRecord = new ListGridRecord();
        //      testRecord.setAttribute("bank", "BNP");
          //    testRecord.setAttribute("currency", "EUR");
          //    testRecord.setAttribute("date", "today");
            //  testRecord.setAttribute("value", new Double(20));
            //  Record[] records = new Record[1];
           //   records[0] = testRecord;
          //    cubeGrid.setData(records);
      
              cubeGrid.setDataSource(dataSource);
              cubeGrid.setAutoFetchData(true);
      
              addMember(cubeGrid);
          }
      }
      There is no log in the Smart Developer console, however in my eclipse run console I view this exception:
      Code:
      2011-12-21 10:46:07,538 FATAL [gwt-log] - Uncaught Exception:
      com.google.gwt.core.client.JavaScriptException:
      (TypeError): Cannot read property 'facet' of undefined
       stack: TypeError: Cannot read property 'facet' of undefined
          at Object.isc_CubeGrid_createRowHeaderBars [as createRowHeaderBars] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Analytics.js:445:236)
          at Object.isc_CubeGrid_createChildren [as createChildren] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Analytics.js:406:116)
          at Object.isc_ListGrid_prepareForDraw (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Grids.js:1470:6)
          at Object.isc_c_Class_invokeSuper [as invokeSuper] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Core.js:308:93)
          at Object.isc_c_Class_Super [as Super] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Core.js:300:170)
          at Object.isc_CubeGrid_prepareForDraw [as prepareForDraw] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Analytics.js:455:96)
          at Object.isc_ListGrid_draw (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Grids.js:1462:123)
          at Object.isc_c_Class_invokeSuper [as invokeSuper] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Core.js:308:93)
          at Object.isc_c_Class_Super [as Super] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Core.js:300:170)
          at Object.isc_CubeGrid_draw [as __draw] (http://jhu.vesinet.alsyon-tech.com:8080/alphee/gwt/cashPosition/sc/modules/ISC_Analytics.js:456:84)
       type: non_object_property_load
       arguments: facet,
       __gwt_ObjectId: 115
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
          at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
          at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
          at com.smartgwt.client.widgets.BaseWidget.draw(BaseWidget.java)
          at com.smartgwt.client.widgets.BaseWidget.getElement(BaseWidget.java:289)
          at com.smartgwt.client.widgets.BaseWidget.getElement(BaseWidget.java:261)
          at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:94)
          at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:97)
          at com.alsyontech.alphee.gwt.entrypoint.AbstractEntryPoint.doOnModuleLoad(AbstractEntryPoint.java:22)
          at com.alsyontech.common.gwt.misc.entrypoint.BaseEntryPoint$1.execute(BaseEntryPoint.java:37)
          at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
          at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:229)
          at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:389)
          at com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78)
          at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:139)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:157)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
          at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
          at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:126)
          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:214)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          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:157)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
          at java.lang.Thread.run(Thread.java:662)

      Comment


        #4
        This may not be the only problem, but one problem is that you are testing in Chrome Development mode, and Chrome has bugs that make it not work with GWT development mode (see FAQ).

        Comment


          #5
          Second problem: a clientCustom DataSource should not be clientOnly. You can remove your whole clientCustom implementation and just use clientOnly with a simple call to setCacheData() to provide the hardcoded data.

          Comment


            #6
            Thank you for the reply.
            In fact, I use a not clientOnly custom data source. The code that I posted is just a sample for you to test. The core is that it seems the CubeGrid cannot work with a custom data source to auto fetch the data while ListGrid can do it. At this moment, I have difficults in using a smart data source: I cannot integrate the RPCManager into our existing spring controller with spring security (you can my other problem here:http://forums.smartclient.com/showthread.php?p=78020#post78020).
            So if I stick to use a custom data source, do I have to fetch the data manually and use CubeGrid.setData? Why a cubeGrid cannot work with a custom data source?

            As for the browser, I have tested it also in the firefox. Always the same Javascript exception.

            Comment


              #7
              CubeGrids work fine with custom DataSources, but not with broken custom DataSources and/or broken CubeGrid config.

              So again your test case was flawed in the ways we indicated, however, a third problem is that if you want to use load on demand you do need to tell the CubeGrid what *facetValues* exist in advance. Otherwise it does not know what data to request to fill the viewport. If you don't want to specify facetValues in advance, use setData() to provide the complete dataset at once.

              Comment


                #8
                You are right: the "third problem" is the real cause: the CubeGrid need to know all the possible facetValues in advance, even before it fetchs data from the data source. Thank you again for the reply.

                Comment

                Working...
                X