Announcement

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

    Exception when Using "localeFloat" and "localeCurrency" Fields

    Hi Isomorphic. As mentioned in this post, when using the es_CO locale (or other Spanish language locales), and typing a decimal like 0,3333 in a field of type "localeFloat" or "localeCurrency" (which expect the comma to be used as decimal separator for this locale), the value is properly recognized. But changing the value to 0.3333 generates an undefined exception:

    *08:27:48.027:KPR7:WARN:Log:java.lang.ClassCastException [No error.stack available]
    Breaking on exception: java.lang.ClassCastException
    After this, the application turns unresponsive.

    Here is a simple test case:

    Code:
    [B]buffer_history.ds.xml[/B]
    <?xml version="1.0" encoding="utf-8"?>
    <DataSource
        ID="buffer_history"
        serverType="sql"
        tableName="buffer_history"
        xmlns:fmt="focuss/fmt">    
    
        <fields>
            <field name="id" primaryKey="true" hidden="true"/>
            <field name="sku"/>
            <field name="location"/>
            <field name="buffer_size" type="localeFloat"/>
            <field name="unit_price" type="localeCurrency"/>
            <field name="movements_update_date" format="dd/MM/yyyy"/>        
        </fields>
    </DataSource>
    Code:
    [B]TestCases.java[/B]
    public class TestCases implements EntryPoint {  
        public void onModuleLoad() {      
            ListGrid grid = new ListGrid(DataSource.get("buffer_history"));
            grid.setAutoFetchData(true);
            grid.setCanEdit(true);
            
            HLayout layout = new HLayout();
            layout.setWidth100();
            layout.setHeight100();
            layout.addMember(grid);
            layout.show();
        }
    }
    What I am doing wrong here?

    I am using SmartGWT 6.0p 2016-09-17 and Chrome Version 53.0.2785.116 m.
    Last edited by carlossierra; 19 Sep 2016, 15:28.

    #2
    That's the only information you get about the error? There should be more, especially in Chrome.

    You may need to try compiled mode or SuperDevMode. And if you are looking only at the Eclipse console, remember to always look in the Developer Console.

    Comment


      #3
      One more note: the fact that you see a ClassCastException here strongly suggests a mismatch between the SmartGWT code you're using and the core JS libraries. Since this seems to be persisting for you, you may need to clear cache, clear the GWT unitcache and restart the IDE and browser.

      Comment


        #4
        Hi Isomorphic. To clarify some points:
        • Yes, I am using SuperDevMode.
        • I just cleared my cache, my GWT unitcache and restarted everything (but this is something I had already done previously, when creating the test case). This didn't solve it. In fact, this is happening in two different projects, in two different workspaces (my real application and my test case application), and in all browsers I've tried it (Edge, Chrome, IExplorer).
        • I am attaching a screenshot where I show you side by side the Chrome Console and Developer Console (Results and Server Logs tabs) error messages (highlighted in red). In this example, I went the other way, trying to use the comma as decimal separator with es_US as locale. The same exception is thrown.
        • Finally, after the exception is thrown, if I try to go to other cells, the errors highlighted in blue in the image show up in.
        Please advice If you think I need to look at other things! Any other ideas?

        Thanks!

        Click image for larger version

Name:	ApplicationErrors.png
Views:	77
Size:	623.7 KB
ID:	240332

        Comment


          #5
          One more thing: if I remove the type="localeFloat" or type="localeCurrency" from these field's definitions in the data source descriptor, now the application won't crash, but this message is presented whenever I try to use an "unexpected" decimal separator.

          Click image for larger version

Name:	Error.png
Views:	80
Size:	6.3 KB
ID:	240334

          Comment


            #6
            You're using a locale which is not supported by SmartGWT - there are around 20 Spanish variants and we only presently support native Spanish/Spain - "es".

            You should have seen a 404 in your console, pointing out that the es_CO locale was not found.

            If you want to add translations for Spanish in Colombia, you can do so at getlocalization.com/Isomorphic, where you can also see the list of supported locales.
            Last edited by Isomorphic; 19 Sep 2016, 23:15.

            Comment


              #7
              Thanks Isomorphic for your response. But I still think there's something wrong here, because this also happens when using en_US as locale and comma as decimal separator, as can be seen in the image I shared in post # 4.

              Comment


                #8
                We don't support that locale string either - SmartGWT Language Packs are not one-to-one with GWT locales. You can see which langauge packs are supported at getlocalization.com/Isomorphic.

                Comment


                  #9
                  Thanks Isomorphic.

                  Comment


                    #10
                    Hi Isomorphic. Sorry for being so persistent, but I did a couple more tests, using now plain 'es' and 'en' as locales, and the "unexpected" behavior is still present. Take a look at the attached image.
                    Also, I didn't get the 404 message you mentioned in post # 6, in any of all these tests (en, es, en_US or es_CO).

                    Click image for larger version

Name:	LocaleErrorEN.png
Views:	77
Size:	352.2 KB
ID:	240346

                    Comment


                      #11
                      Please show the code you're using to load these locales (from your gwt.xml file).

                      Comment


                        #12
                        Here you go:

                        Code:
                        <?xml version="1.0" encoding="UTF-8"?>
                        <!--
                            When updating your version of GWT, you should also update this DTD reference,
                            so that your app can take advantage of the latest GWT module capabilities.
                        -->
                        <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
                            "http://gwtproject.org/doctype/2.7.0/gwt-module.dtd">
                            
                            <module rename-to='testcases'>
                            
                            <!-- Inherit the core Web Toolkit stuff -->
                            <inherits name='com.google.gwt.user.User'/>
                            
                            <!-- Inherit SmartGWT developer tools module -->
                            <inherits name="com.smartgwt.tools.SmartGwtTools"/>
                            <inherits name="com.smartgwtee.tools.Tools"/>
                            
                            <!-- Inherit theSmartGWT basic module -->
                            <inherits name="com.smartgwtee.SmartGwtEENoTheme"/>
                            
                            <!-- Inherit the desired theme to use in the application -->
                            <inherits name="com.smartclient.theme.enterprise.Enterprise"/>
                            
                            <!-- Inherit SmartGWT modules required for charting --> 
                            <!-- Order is important for the modules to work properly -->
                            <inherits name="com.smartgwt.Drawing"/>
                            <inherits name="com.smartgwt.Charts"/>
                            
                            <!-- Specify the app entry point class -->
                            <entry-point class='com.myApp.testcases.client.TestCases'/>
                            
                        [B]    <!-- Specify the supported languages -->
                            <extend-property name="locale" values="en"/>
                            <extend-property name="locale" values="es"/>[/B]
                        
                            <!-- Specify the paths for translatable code -->
                            <source path='client'/>
                            <source path='shared'/>
                        
                            <!-- allow Super Dev Mode -->
                            <add-linker name="xsiframe"/>
                            
                            <!-- Specify supported browsers (in order): Chrome/Safari, IE, Firefox-->
                            <set-property name="user.agent" value="safari"/>
                        <!--     <set-property name="user.agent" value="ie8"/> -->
                        <!--     <set-property name="user.agent" value="gecko1_8"/> -->
                            
                        </module>

                        Comment


                          #13
                          Ok, we see the issue and a fix will be in builds dated September 22 and later. Note that, contrary to our earlier advice, all the GWT locale strings you used, es_CO for example, actually *are* supported for number-formatting - the decimalSymbol and groupingSymbol specified in the SmartGWT language packs are ignored, and those for the current locale used instead.

                          However, you would need to include a valid SmartGWT language pack for message localization.

                          Comment


                            #14
                            Thanks Isomorphic. Indeed, it seemed odd that 'es_CO' ans 'en_US' were not supported, as using them produced the right decimal separators, currency symbols (and symbol location), etc...

                            Also, what do you mean by

                            include a valid SmartGWT language pack for message localization
                            Do you mean in Get Localization? If so, would it be possible to clone/copy the existing 'es' files and start from there? How? I would then make the appropriate changes that differentiate 'es' from 'es_CO'.

                            Anyway, I'll let you know how it goes when the new build is out.

                            Comment


                              #15
                              See the section entitled "Framework Message Localization", here - you can add a meta tag to your bootstrap file that will load a language pack with translations for all builtin messages.

                              It's not clear that getlocalization.com has a user facility that duplicates an existing pack into a new one - let us know if you struggle and we can sort something out from here.

                              Once your new pack is updated, let us know and we'll incorporate it into the builds.

                              Comment

                              Working...
                              X