Announcement

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

    "selectString is not a function" error overriding RestDataSource.transformResponse()

    Browser: any
    SmartGwtVersion: Smart GWT LGPL Edition (2014-04-09 nightly)
    SmartClient Version: v9.1p_2014-04-08/LGPL Development Only (built 2014-04-08)

    Today I've downloaded the latest nightly build of SmartGwt 4.1p and I had the following exception during data loading
    Uncaught exception escaped : com.google.gwt.core.client.JavaScriptException
    (TypeError) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)
    ([JavaScript object(57), JavaScript object(54), JavaScript object(132)]): _3.selectString is not a function
    See the Development console log for details.
    Register a GWT.setUncaughtExceptionHandler(..) for custom uncaught exception handling.
    I followed instructions of this thread, without any success.
    After many experiments, I found that adding a call to super.transformRequest() within the overridden method made everything work like a charm.
    That override of RestDataSource.transformRequest() method without calling super implementation was perfectly working with SmartGWT versions prior to 4.1.

    This seems a breaking change people should be aware of. Maybe the javadoc should be updated, highlighting that custom implementations must still invoke the superclass implementation of transformRequest().

    So is there any better way to workaround this issue?

    Follows an excerpt from a standalone test case, just to ease reproducing the issue.
    Code:
    ...
    final RestDataSource dataSource = new RestDataSource() {
        @Override
        protected Object transformRequest(
                com.smartgwt.client.data.DSRequest dsRequest) {
            // super.transformRequest(dsRequest); //UNCOMMENTING THIS, IT WORKS
            return dsRequest.getData();
        }
    
    };
    dataSource.setDataFormat(DSDataFormat.JSON);
    dataSource.setDataURL("gwt/data.js");
    
    // datasource fields initialization
    {
        final DataSourceIntegerField keyField = new DataSourceIntegerField(
                "id", "ID");
        keyField.setPrimaryKey(true);
        final DataSourceTextField nameField = new DataSourceTextField(
                "name", "Name");
    
        dataSource.setFields(keyField, nameField);
    }
    
    dataSource.fetchData(new Criteria());
    ...

    #2
    We're not seeing an issue with code like you've shown, and neither is the user in the other thread.

    Since what you've posted is obviously not the actual code you're running (it has syntax errors), try running code that has been simplified down to that extent, and, if you're reproducing the issue, please show actual standalone code that shows this error.

    Comment


      #3
      Hello, I have attached full source class and related stacktrace.
      When invocation to
      Code:
      super.transformRequest(dsRequest);
      is commented, I obtain the attached stacktrace, when uncommented, everything works.
      Attached Files

      Comment


        #4
        This doesn't seem to be reproducing a problem, and what's weirder, selectString() is only called during response processing, and only for XML, not JSON.

        Can you:

        1. post the stack trace *using the instructions in the FAQ* - this will be a stack trace of JavaScript methods. Please post the entire contents of the Developer Console logs if there is anything aside from the stack trace

        2. post the data file you're using in your test

        Comment


          #5
          Originally posted by Isomorphic View Post
          This doesn't seem to be reproducing a problem, and what's weirder, selectString() is only called during response processing, and only for XML, not JSON.

          Can you:

          1. post the stack trace *using the instructions in the FAQ* - this will be a stack trace of JavaScript methods. Please post the entire contents of the Developer Console logs if there is anything aside from the stack trace

          2. post the data file you're using in your test
          1. Debugging in devmode, the exception occurs in RestDataSource.js, line 1280
            Code:
            dsResponse.status = this.getValidStatus(data.selectString("//status"));
            The execution flow arrives here because of the if at line 1225
            Code:
            if (dsRequest.dataFormat == "json")
            chrome debugger says that dsRequest.dataFormat is undefined, so, as you said, the code that handles xml data is invoked
          2. I attached the data.js containing data in json format that is loaded,
            the logs at level debug of smartclient console loading the same set of data, compiled with versions
            4.0.0p build 2014-01-05 - SmartClient Core (v9.0p_2014-01-05/LGPL Development Only 2014-01-05) it works
            4.1.0p build 2014-04-08 - SmartClient Core (v9.1p_2014-04-08/LGPL Development Only 2014-04-08) it does not work
          3. I run the code in compiled mode using version 4.1.0p build 2014-04-08, I had not any exception nor logs on console
          Attached Files

          Comment


            #6
            OK, this is actually not a bug. When you don't call super(), you are destroying essentially all of the built-in functionality of the RestDataSource, which is not a valid way to use it.

            It looks like you are not actually trying to use the RestDataSource protocol at all, since by never calling super(), you destroyed all the logic for sending requests in RestDataSource format. If so, you should extend from DataSource, not RestDataSource (the docs recommend this).

            Comment


              #7
              Never asserted there was a bug, just a change about how to override transformRequest.
              Thanks for your answer, have a nice day

              Comment

              Working...
              X