Announcement

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

    Combobox issues with SmartGWT 6.0

    Hi Isomorphic,

    I prepare the migration to SmartGWT 6.0.
    Here is the version I used : SmartClient Version: v11.0p_2016-08-12/LGPL Development Only (built 2016-08-12).

    The issue appears for all comboboxes with optionDataSource, with valueField the integer pk field of the optionDataSource and the displayField a string field of the optionDataSource .
    The combobox must already have a value.
    When i click on the comboBoxItem (with a value), the pick list opened and than i got an error message.
    I can not reproduce it with client datasources.

    I've tried a lot of settings of the ComboBox to determine which is the one that cause me trouble.
    Can you give me any hint, where to look at ?

    Un isolated test case is this, but is not a standalone one because UserDS is server side DS.
    Code:
    ComboBoxItem userComboItem = new ComboBoxItem("userId", "User");
    userComboItem.setOptionDataSource(UserDS.getInstance());
    userComboItem.setValueField(UserDS.UTI_ID);
    userComboItem.setDisplayField(UserDS.UTI_NOM);
    
    DataSource formDS = new DataSource();
    formDS.setClientOnly(true);
    formDS.setFields(new DataSourceField("pk", FieldType.INTEGER), new DataSourceField("userId", FieldType.INTEGER));
    
    DynamicForm form = new DynamicForm();
    form.setDataSource(formDS);
    form.setItems(userComboItem);
    form.setColWidths(1, 350);
    addMember(form);
    
    Map<String, Object> initValues = new HashMap<String, Object>();
    initValues.put("userId", 2);
    form.editNewRecord(initValues);

    On dev mode i got this error
    Code:
    Cannot cast java.lang.Integer to java.lang.String
    java.lang.Class.cast(Class.java:3176)
    com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:163)
    com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:65)
    com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)
    com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:304)
    com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    com.smartgwt.client.data.DataSource.processResponse(DataSource.java)

    On compile mode i got this
    Code:
    lineNumber: 14857 columnNumber: 27: a.indexOf is not a function
    Unknown.vBs(Unknown Source)
    Unknown.CUo(Unknown Source)
    Unknown.BUo(Unknown Source)
    Unknown.Z1r(Unknown Source)
    Unknown.X1r/$wnd.isc.NumberUtil.parseFloat(Unknown Source)
    Unknown.isc.builtinTypes.integer.parseInput(Unknown Source)
    Unknown.isc_FormItem__parseDisplayValue(Unknown Source)
    Unknown.isc_TextItem_mapDisplayToValue(Unknown Source)
    Unknown.isc_c_Class_invokeSuper(Unknown Source)
    Unknown.isc_ComboBoxItem_mapDisplayToValue(Unknown Source)
    Unknown.isc_ComboBoxItem__updateValue(Unknown Source)
    Unknown.isc_FormItem_updateValue(Unknown Source)
    Unknown..$19v(Unknown Source)
    Unknown..handleDataArrived(Unknown Source)
    Unknown..$19n/&lt;.dataArrived(Unknown Source)
    Unknown.isc_ListGrid__dataArrived(Unknown Source)
    Unknown.isc_ListGrid__observeData/&lt;(Unknown Source)
    Unknown.observation(Unknown Source)
    Unknown.isc_ResultSet__doneDataArriving(Unknown Source)
    Unknown.isc.A.fetchRemoteDataReply(Unknown Source)
    Unknown.isc_c_Class_invokeSuper(Unknown Source)
    Unknown.isc_c_Class_Super(Unknown Source)
    On compile mode, dev center, i got this
    Code:
    13:55:39.558:IBLR0:WARN:Log:TypeError: a.indexOf is not a function
    Stack from error.stack:
    vBs() @ acquityCX/512BDC5CA1693542DDB0E2FC94611F1A.cache.html:14857
    CUo() @ acquityCX/512BDC5CA1693542DDB0E2FC94611F1A.cache.html:24669
    BUo() @ acquityCX/512BDC5CA1693542DDB0E2FC94611F1A.cache.html:18494
    Z1r() @ acquityCX/512BDC5CA1693542DDB0E2FC94611F1A.cache.html:21341
    X1r/$wnd.isc.NumberUtil.parseFloat() @ acquityCX/512BDC5CA1693542DDB0E2FC94611F1A.cache.html:25133
    isc.builtinTypes.integer.parseInput() @ acquityCX/sc/modules/ISC_Foundation.js:796
    FormItem._parseDisplayValue() @ acquityCX/sc/modules/ISC_Forms.js:947
    TextItem.mapDisplayToValue() @ acquityCX/sc/modules/ISC_Forms.js:1711
    Class.invokeSuper() @ acquityCX/sc/modules/ISC_Core.js:273
    ComboBoxItem.mapDisplayToValue() @ acquityCX/sc/modules/ISC_Forms.js:2487
    ComboBoxItem._updateValue() @ acquityCX/sc/modules/ISC_Forms.js:2425
    FormItem.updateValue() @ acquityCX/sc/modules/ISC_Forms.js:1063
    FormItem.elementChanged() @ acquityCX/sc/modules/ISC_Forms.js:1157
    DynamicForm.bubbleItemHandler() @ acquityCX/sc/modules/ISC_Forms.js:530
    DynamicForm.elementChanged() @ acquityCX/sc/modules/ISC_Forms.js:531
    TextItem._nativeElementBlur() @ acquityCX/sc/modules/ISC_Forms.js:1692
    FormItem.._nativeBlurHandler() @ acquityCX/sc/modules/ISC_Forms.js:642
    FormItem._nativeBlurHandler() @ acquityCX/sc/modules/ISC_Forms.js:641
    Canvas.setFocus() @ acquityCX/sc/modules/ISC_Core.js:2924
    Canvas.focus() @ acquityCX/sc/modules/ISC_Core.js:2926
    [c]EventHandler.doHandleMouseDown() @ acquityCX/sc/modules/ISC_Core.js:1505
    [c]EventHandler.handleMouseDown() @ acquityCX/sc/modules/ISC_Core.js:1494
    [c]EventHandler.dispatch() @ acquityCX/sc/modules/ISC_Core.js:1783
    anonymous() @ acquityCX/sc/modules/ISC_Core.js:58
    Thanks in advance for your help.

    #2
    This appears to be some kind of issue with invalid data coming from the DataSource, especially since you were unable to reproduce it with a clientOnly DataSource.

    Are you able to reproduce this problem using any of the sample server-based DataSources provided in the Showcase? That would allow us to reproduce the problem so we can fix it.

    Comment


      #3
      Hi Isomorphic,

      I've tried a lot of things but no solution.
      I can not reproduce with a dataSource with XML data fetched from server side like this
      Code:
      setRecordXPath("/list/user");
      setDataURL("users.xml");
      setClientOnly(false);
      When i click on the picker icon, the pick listgrid shows up and start fetching remote data.
      What is weird is that on ListGrid dataArrived, it is called the ComboBoxItem.updateValue even before i select a line in the pick list.
      So ComboBoxItem.updateValue will use values of the initial fetch, is it ?
      Does the initialFetch have a problem ?
      I do not understand why ComboBoxItem.updateValue is called. Maybe because of the blur.
      More, ComboBoxItem.updateValue will call ComboBoxItem.mapDisplayToValue which will call FormItem.parseDisplayValue as an int !!!
      I know a lot of things changed on 6.0 but maybe you can look for something on this side.

      So here is the difference between my GwtRPCDataSource and the XML data source.
      The initial fetch on my datasource return only one record, and from the XML datasource it will return all records.
      Am i right ?


      One other thing that i discovered, if the form that contains the combobox have no datasource set, there is no error.
      Code:
      DynamicForm form = new DynamicForm();
      //form.setDataSource(formDS);
      form.setItems(userComboItem);
      Maybe this will give you a hint.

      I understand that without a standalone testcase it is impossible for you to debug, but i do not know how to isolate this.
      I'll appreciate any hint or a way to debug this.

      Comment


        #4
        It's normal to see updateValue running in this circumstance, related to acquiring a displayValue for the first time, or related to clearing the pendingDisplayValue.

        Again, your issue here strongly suggests invalid data coming from the DataSource. That's the main thing to look at. You may be returning Strings where Integers should be returned, or vice versa.

        It's also very strange that your stack traces show multiple stack frames underneath out method NumberUtil.parseFloat(), and further, that those methods appear to be GWT-generated obfuscated code. NumberUtil.parseFloat() calls only the native JavaScript methods parseFloat() and string.replace(). The stack you're seeing suggests that you may be using a GWT library that tries to replace these native JavaScript methods with GWT-generated code, and that the generated code is broken. If you aren't already aware of this going on, you can use the browser's built-in Developer Tools to see what's happening at the lowest few stack frames.

        Comment


          #5
          Hi Isomophic,

          After 4 days of searching i gave up.
          I switched back to SmartGWT 5.1. With the same environnement, same code it works.
          I will try SGWT 6.0 later. Maybe someone will have a similar issue and will be able to create a standalone testcase.

          Thank you for your help.

          Comment


            #6
            Did you try either of the two lines of investigation we suggested? Each should take just a few moments to look into, so we're not sure where those 4 days went.

            Comment


              #7
              Really appreciate your quick answer.
              I'm still using the old dev mode, so lot of things are really slow.
              About invalid data coming from server, it is simple to debug, in my source code where ListGridRecord are created.
              I thought of charset issue, but everything is UTF8 for me, mysql db, tomcat jvm, files,... I tried with the jdbc connection params UTF8 but nothing.
              I can assure you that userId is Integer and userName is String.

              It is more difficult for me when it comes to javascript. That means i am not an expert in compiled javascript.
              Ive tried debugging with Chrome developer tools as you suggest it.
              But using source maps, i found the same lines as those in ISC_Forms.js than entered in $wnd.SmartGWT.convertToJavaType where i see the argument the integer value, and afterwards in a lot of compiled javascript functions where i do not undestand much thing.
              Not even capable to found the line that throws the exception.

              Comment


                #8
                Look at #4 above. Do you or don't you have some other GWT library or third-party JavaScript library in your project? That's the first thing to look at. You could also just evaluate the JavaScript for the native parseFloat function (literally just evaluate the expression "parseFloat") and if it says something other than "[native code]" then you've got something in your project that is overriding this built-in browser functionality.

                Comment


                  #9
                  Sorry for the long delay, my project does not GWT compile any more. I can not test parseFloat.
                  I will return with the answer.
                  I use gwt-maps and gwt-visualization. It works with SGWT 5.1.

                  Comment


                    #10
                    When evaluating parseFloat in browser's page javascript I got this.
                    Code:
                    function parseFloat() {
                        [native code]
                    }

                    I compiled GWT with stackTrace emulated and here is the new stack trace.
                    Code:
                    (TypeError) : this$static.indexOf is not a function
                    Unknown.com_google_gwt_core_client_impl_StackTraceCreator$CollectorEmulated_$collect__Lcom_google_gwt_core_client_impl_StackTraceCreator$CollectorEmulated_2Lcom_google_gwt_core_client_JsArrayString_2(JsArrayString.java:42)
                    Unknown.com_google_gwt_core_client_impl_StackTraceCreator$CollectorEmulated_fillInStackTrace__Ljava_lang_Throwable_2V(StackTraceCreator.java:180)
                    Unknown.com_google_gwt_core_client_impl_StackTraceCreator_fillInStackTrace__Ljava_lang_Throwable_2V(StackTraceCreator.java:518)
                    Unknown.java_lang_Throwable_$fillInStackTrace__Ljava_lang_Throwable_2Ljava_lang_Throwable_2(Throwable.java:115)
                    Unknown.java_lang_Throwable_Throwable__V(Throwable.java:51)
                    Unknown.java_lang_Exception_Exception__V(Exception.java:25)
                    Unknown.java_lang_RuntimeException_RuntimeException__V(RuntimeException.java:25)
                    Unknown.com_google_gwt_core_client_JavaScriptException_JavaScriptException__Ljava_lang_Object_2Ljava_lang_String_2V(JavaScriptException.java:117)
                    Unknown.com_google_gwt_core_client_JavaScriptException_JavaScriptException__Ljava_lang_Object_2V(JavaScriptException.java:109)
                    Unknown.com_google_gwt_lang_Exceptions_getCachableJavaScriptException__Ljava_lang_Object_2Lcom_google_gwt_core_client_JavaScriptException_2(Exceptions.java:45)
                    Unknown.com_google_gwt_lang_Exceptions_wrap__Ljava_lang_Object_2Ljava_lang_Object_2(Exceptions.java:29)
                    Unknown.java_lang_String_$indexOf__Ljava_lang_String_2Ljava_lang_String_2II(String.java:727)
                    Unknown.java_lang_String_$startsWith__Ljava_lang_String_2Ljava_lang_String_2IZ(String.java:931)
                    Unknown.com_google_gwt_i18n_client_NumberFormat_$parse__Lcom_google_gwt_i18n_client_NumberFormat_2Ljava_lang_String_2_3ID(NumberFormat.java:1049)
                    Unknown.com_google_gwt_i18n_client_NumberFormat_$parse__Lcom_google_gwt_i18n_client_NumberFormat_2Ljava_lang_String_2D(NumberFormat.java:1020)
                    Unknown.com_smartgwt_client_util_I18nUtil_parseNum__Ljava_lang_String_2D(I18nUtil.java:114)
                    Unknown.anonymous(I18nUtil.java:68)
                    Unknown.com_smartgwt_client_data_DataSource_$processResponse__Lcom_smartgwt_client_data_DataSource_2Ljava_lang_String_2Lcom_smartgwt_client_data_DSResponse_2V(DataSource.java:4292)
                    I think that Datasource consider that the value of userId is a String even if it is an integer, so it calls parseNum(String) with an Integer parameter.
                    In debug, I confirm the userId field is a DataSourceIntegerField and the data is valid, it is a real Integer as indicated in the message ( Cannot cast java.lang.Integer to java.lang.String)..

                    Comment


                      #11
                      Looking at this, it seems as though your code is passing an Integer as the requestId parameter of DataSource.processResponse(), where a String is what is expected. Both this stack trace and the previous one involving processResponse() suggest this.

                      The later crash in the ComboBox is probably a downstream consequence of this error.

                      Comment


                        #12
                        I am using GwtRpcDataSource and no requestId is assign in our code. Is SmartGWT generated.
                        The format i got in debugging is : isc_userDS_2$6275.

                        Comment


                          #13
                          Yes, that's a valid requestId, and it's a String obviously - but this doesn't say anything about whether your code, or something in your project, is doing something wrong.

                          You see, DataSource.java:processResponse() does not have any calls to I18nUtil:

                          https://github.com/isomorphic-softwa...ataSource.java

                          Your stack traces are really strange, and show seemingly impossible things. We would guess that either:

                          1. you have some kind of special GWT plugin or something that takes the $6275 in the requestId string and injects code to do something i18n-related with it.

                          or

                          2. your project is just corrupt in some way, and at least for 6.0, GWT is generating invalid code. The project may need to be rebuilt, or GWT re-installed, or similar

                          Either way there's nothing we can do for you, because you're showing crashes in code that doesn't exist

                          Comment


                            #14
                            Obviously we are not looking at the same source. You show me a link to a file DataSource.java with only 3588 lines or the one present in the last build of 6.0p
                            http://www.smartclient.com/builds/Sm...GPL/2016-08-23,
                            the mainsrc.zip contains a DataSource.java with 7349 lines.

                            DataSource.java 4292 refers to processResponse for dataProtocol:"clientCustom".
                            self.processResponse(requestId, dsResponse.@com.smartgwt.client.core.DataClass::getJsObj()());
                            which somehow call the innerMethod "isc.NumberUtil.parseFloat" as specified in trace anonymous(I18nUtil.java:68).

                            I understand it is difficult to found the problem without a standalone testcase as described in FAQ (extension of showcase), but the problem is linked somehow to GWT-RPC datasource, to custom operations.
                            I managed to create a standalone testcase. It is not a simple file to post, but a project with many files (Service, ServiceAsync, Servlet, web.xml,...).

                            Comment


                              #15
                              Look at any version of DataSource.java you like, processResponse() doesn't have a call to I18nUtil.java.

                              Aside from GWT-RPC being strongly discouraged by us (see FAQ) and partially abandoned by Google, we don't want to spend time analyzing a test case until we see that you're getting sane stack traces, as again your environment appears corrupt in some way.

                              Comment

                              Working...
                              X