Announcement

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

    4.1 FloatItem decimal separator (locale bug)

    1. SmartGWT 4.1 / SmartClient Version: v9.1p_2014-03-05/PowerEdition Deployment (built 2014-03-05)
    2. Browsers: IE 9 & 10, Chome, Firefox

    The Bad news: The FloatItem is using '.' (period) instead of ',' (comma) as the decimal separator.
    (check the image)

    Sample Code:
    Code:
    package org.microcodigo.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.i18n.client.DateTimeFormat;
    import com.google.gwt.i18n.client.LocaleInfo;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.DateItem;
    import com.smartgwt.client.widgets.form.fields.FloatItem;
    import com.smartgwt.client.widgets.form.fields.StaticTextItem;
    import com.smartgwt.client.widgets.form.fields.TextAreaItem;
    import java.util.Arrays;
    
    /**
     * Main entry point.
     *
     * @author kiipper
     */
    public class MainEntryPoint implements EntryPoint {
    
        /**
         * Creates a new instance of MainEntryPoint
         */
        public MainEntryPoint() {
        }
    
        /**
         * The entry point method, called automatically by loading a module that
         * declares an implementing class as an entry-point
         */
        @Override
        public void onModuleLoad() {
    
            String[] allLocales = LocaleInfo.getAvailableLocaleNames();
    
            DynamicForm form = new DynamicForm();
            form.setWidth100();
            form.setHeight100();
    
            StaticTextItem localeItem = new StaticTextItem("locale", "Locale");
            String localeName = LocaleInfo.getCurrentLocale().getLocaleName();
            localeItem.setValue(localeName);
    
            FloatItem floatItem = new FloatItem("float", "Float Item");
            floatItem.setValue(123456.789);
    
            DateItem dateItem = new DateItem("date", "Date Item");
            DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-mm-dd");
            dateItem.setValue(dtf.parse("1234-12-13"));
    
            TextAreaItem allLocaleItem = new TextAreaItem("allLocales", "Avaliable Locales");
            allLocaleItem.setRowSpan(20);
            allLocaleItem.setValue(Arrays.toString(allLocales).replaceAll(",", "\n"));
    
            form.setItems(localeItem, floatItem, dateItem, allLocaleItem);
            form.draw();
        }
    }
    gwt.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
    
    <module>
        <inherits name="com.google.gwt.user.User"/>
    
        <!-- Portuguese in Brazil-->
        <extend-property name="locale" values="pt_BR"/>
        <set-property name="locale" value="pt_BR"/>
        <set-property-fallback name="locale" value="pt_BR"/>
        
         <!--English USA-->
    <!--    <extend-property name="locale" values="en_US"/>
        <set-property name="locale" value="en_US"/>
        <set-property-fallback name="locale" value="en_US"/>-->
        
        <!--spanish-->
    <!--    <extend-property name="locale" values="es_ES"/>
        <set-property name="locale" value="es_ES"/>
        <set-property-fallback name="locale" value="es_ES"/>-->
        
        <!-- German -->
    <!--    <extend-property name="locale" values="de"/>
        <set-property name="locale" value="de"/>
        <set-property-fallback name="locale" value="de"/>-->
        
        <inherits name="com.smartgwt.SmartGwt"/>
    
        <inherits name="com.smartgwtee.tools.Tools"/>
        <inherits name="com.smartgwt.Charts"/>
        <inherits name="com.smartgwt.Drawing"/>
      
        <inherits name="com.google.gwt.i18n.I18N"/>
    
    
        <entry-point class="org.microcodigo.client.MainEntryPoint"/>
    
    </module>

    It is not working for 'de' Germany, 'es' Spanish, 'pt' Portuguese.

    The good news is that the date are working fine (format and month names)
    Attached Files

    #2
    Please see the docs for FieldType.

    Comment


      #3
      It's Working! Code sample!

      Thank you, for your quick response.

      For anyone that might be in trouble with that, use the following code:
      Code:
      ...
        FloatItem floatItem = new FloatItem("float", "Float Item");
        floatItem.setValue(123456.789);
        floatItem.setType(FieldType.LOCALEFLOAT.getValue());
      ...

      Comment

      Working...
      X