Announcement

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

    i18n DateChooser validation error

    Hi,

    i am starting to implement i18n. The first stap was to introduce the german language for the smartGWT parts.

    I added:
    <extend-property name="locale" values="de"/> to the .gwt.xml
    and
    <meta name="gwt:property" content="locale=de_DE"> to the .html

    This is working fine. The dates are shown in the german format (DD.MM.YYYY). Every smartgwt menus are german too.

    Now i use the DateChooser to edit the Date or when i edit the Date manually, then smartGWT will show an invalid icon. I think smartGWT checks for this format (MM.DD.YYYY) because with that format it won't show the invalid icon? But the DateChooser is also using the (DD.MM.YYYY) format.


    And another "problem" a float/double value will still be in (xx.xx) format not the european (xx,xx) is there a i18n way from smartGWT for that?

    #2
    See DateUtil - methods on this class allow you to change date display and input formats system-wide.

    Use GWT's NumberFormat in conjunction with the ability to centrally define formatting and parsing logic via SimpleType to create locale-sensitive decimals.

    Comment


      #3
      Ok but this won't work with i18n ? Because i have to support more then one language.

      And this looks like a bug. Because i only setup the locale to de and the editing of dates are wrong.

      I did make some tests and the result are followed(in locale=de):

      Date display: DD.MM.YYYY (right)
      Datechooser inserts: DD.MM.YYYY (right)
      Date read by datasource: DD.MM.YYYY (right)
      edit manual the datefield: MM.DD.YYYY (wrong)

      but this manual edit date will automatically changed to european version. I insert MM.DD.YYYY then it will be shown as DD.MM.YYYY.

      This can't be supposed to be right because the Datachooser always will insert a wrong/invalid date.

      We are using the smartGWT 2.5 version and GWT 2.3 version.

      Comment


        #4
        We suspect there's something wrong with your project, although it's not clear what.

        You seem to be saying that the DateChooser somehow inserts the wrong date in the wrong format, but that's not possible, because the DateChooser passes the chosen date back to the DateItem as a Date instance, not a String.

        So this suggests that the actual problem is that you have set conflicting formats for date display and date input via DateUtil APIs. We know you're saying you haven't set anything, yet its clear that two conflicting settings have been applied somewhere.

        Comment


          #5
          I never set anything except in the ds.xml file. Where i set type="date".

          In the BasicDataSource i return a map with the date inside.

          If i set on the client side:
          fieldPickUpDate.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE);

          Then it is working properly. But then it won't switch back to american date, if the location is set to.

          I have no idea where the problem comes from?

          Edit: ok strange. I tested now with:
          fieldPickUpDate.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE);

          And when i choose locale=en then it will change from DD.MM.YYYY to DD/MM/YYYY.
          A half english and half german date display? :/
          Last edited by feschuck; 5 Dec 2011, 00:49.

          Comment


            #6
            We can't tell, from this information, how you've ended up in a broken state. If you start from scratch with a fresh SDK and show minimal changes to a sample project and you can arrive in this state, then let us know what those minimal changes are (don't just upload a whole project) and we'll look at what's wrong.

            Comment


              #7
              Ok i made a simple example with my problem.

              ###client/TestGui.java###
              Code:
              public class TestGui implements EntryPoint {
              
              	public void onModuleLoad() {
              		DataSource ds = DataSource.get("testDataSource");
              		ListGrid listGrid = new ListGrid();
              		listGrid.setDataSource(ds);
              		listGrid.setAutoFetchData(true);
              		listGrid.setCanEdit(true);
              		listGrid.draw();
              	}
              }
              ###server/TestDataSource.java###
              Code:
              public class TestDataSource extends BasicDataSource{
              	@Override
                  public DSResponse executeFetch(DSRequest req) throws Exception {
                      List records = fetchRecords(req.getCriteria());
                      DSResponse dsResponse = new DSResponse(records);
                      return dsResponse;
                  }
                  
                  private List fetchRecords(Map criteria) {
                  	List retval = new ArrayList();
                  	
                  	for(Integer i=0; i<5; i++){
                  		Map record = new HashMap();
                  		record.put("id", i.toString());
                  		record.put("text", "Text");
                  		record.put("testDate", new Date());
                  		
                  		retval.add(record);
                  	}
                  	
                      return retval;
                  }
              }
              ###ds/testDataSource.ds.xml###
              Code:
              <DataSource ID="testDataSource"
                serverConstructor="com.test.smartgwt.server.TestDataSource">
                  <fields>
                      <field name="id" 			type="string" primaryKey="true" hidden="true"/>
                      <field name="text"			type="string"/>
                      <field name="testDate" 		type="date" />
                  </fields>
              </DataSource>
              ###TestGui.gwt.xml###
              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              <module rename-to='testgui'>
              
                <!-- Other module inherits                                      -->
                <inherits name='com.google.gwt.user.User'/>
                <inherits name="com.smartgwt.tools.SmartGwtTools"/>
                <inherits name="com.smartgwtee.tools.Tools"/>
                <inherits name="com.smartgwtee.SmartGwtEE"/>
                <inherits name="com.google.gwt.i18n.I18N"/>
                <extend-property name="locale" values="de_DE"/>
              
                <!-- Specify the app entry point class.                         -->
                <entry-point class='com.test.smartgwt.client.TestGui'/>
              
                <!-- Specify the paths for translatable code                    -->
                <source path='client'/>
                <source path='shared'/>
              </module>
              ###TestGui.html###
              Code:
              <!doctype html>
              <!-- The DOCTYPE declaration above will set the     -->
              <!-- browser's rendering engine into                -->
              <!-- "Standards Mode". Replacing this declaration   -->
              <!-- with a "Quirks Mode" doctype is not supported. -->
              
              <html>
                <head>
                  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
              	<meta name="gwt:property" content="locale=de_DE">
                  <!--                                                               -->
                  <!-- Consider inlining CSS to reduce the number of requested files -->
                  <!--                                                               -->
                  <link type="text/css" rel="stylesheet" href="TestGui.css">
              
                  <!--                                           -->
                  <!-- Any title is fine                         -->
                  <!--                                           -->
                  <title>Web Application Starter Project</title>
                  <script>
              		var isomorphicDir = "testgui/sc/";
              	</script>
                  <!--                                           -->
                  <!-- This script loads your compiled module.   -->
                  <!-- If you add any GWT meta tags, they must   -->
                  <!-- be added before this line.                -->
                  <!--                                           -->
                  <script type="text/javascript" language="javascript" src="testgui/testgui.nocache.js"></script>
                  <script src="testgui/sc/DataSourceLoader?dataSource=testDataSource"></script>
                </head>
              
                <!--                                           -->
                <!-- The body can have arbitrary html, or      -->
                <!-- you can leave the body empty if you want  -->
                <!-- to create a completely dynamic UI.        -->
                <!--                                           -->
                <body>
              
                  <!-- OPTIONAL: include this if you want history support -->
                  <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
                  
                  <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
                  <noscript>
                    <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
                      Your web browser must have JavaScript enabled
                      in order for this application to display correctly.
                    </div>
                  </noscript>
              
                </body>
              </html>
              Is there a mistake on my side?

              Comment


                #8
                Are you using unpatched 2.5? Grab the latest 2.5.x build from SmartClient.com/builds to get all post-2.5 fixes.

                Comment


                  #9
                  Ok i tried out followed nightly build: 2011-12-15
                  from:
                  http://www.smartclient.com/builds/SmartGWT/2.x/EnterpriseEval/

                  same behaivor then in the release-build.

                  After that i tried out the 3.0 version. i switched the project dependencys from the 2.x jars to the 3.0 jars.

                  Then i get followed exception, if i try to edit the date:

                  Code:
                  15:44:18.097 [ERROR] [testgui] 15:44:18.104:WARN:Log:TypeError: isc.Validator.getValidatorType is not a function
                      Canvas.validateField(_1=&gt;{Obj},  _2=&gt;[object Array],  _3=&gt;[object Date],  _4=&gt;{Obj},  _5=&gt;{Obj}) @ testgui/sc/modules/ISC_Core.js:3919
                      ListGrid.validateFieldValue(newValue=&gt;[object Date], oldValue=&gt;[object Date], record=&gt;{Obj}, field=&gt;{Obj}, rowNum=&gt;1, colNum=&gt;1, undefined=&gt;undef) @ testgui/sc/modules/ISC_Grids.js:2442
                      ListGrid.validateCellValue(rowNum=&gt;1, colNum=&gt;1, newValue=&gt;[object Date], oldValue=&gt;[object Date]) @ testgui/sc/modules/ISC_Grids.js:2437
                      ListGrid.validateRowValues(_1=&gt;{Obj},  _2=&gt;{Obj},  _3=&gt;1,  _4=&gt;[object Array]) @ testgui/sc/modules/ISC_Grids.js:2428
                      ListGrid.validateRecord(_1=&gt;1,  _2=&gt;undef) @ testgui/sc/modules/ISC_Grids.js:2425
                      ListGrid.validateRow(_1=&gt;1) @ testgui/sc/modules/ISC_Grids.js:2422
                      ListGrid.saveEdits(_1=&gt;&quot;click_outside&quot;,  _2=&gt;undef) @ testgui/sc/modules/ISC_Grids.js:2341
                      ListGrid._saveAndHideEditor(&quot;click_outside&quot;) @ testgui/sc/modules/ISC_Grids.js:2291
                      ListGrid.cellEditEnd(_1=&gt;&quot;click_outside&quot;) @ testgui/sc/modules/ISC_Grids.js:2256
                      ListGrid._handleClickOutsideEditor() @ testgui/sc/modules/ISC_Grids.js:2116
                      anonymous() @ testgui/sc/modules/ISC_Grids.js:1992
                      [c]Class.fireCallback(_1=&gt;anonymous) @ testgui/sc/modules/ISC_Core.js:325
                      EventHandler._clickMaskClick({Obj}) @ testgui/sc/modules/ISC_Core.js:1874
                      [c]EventHandler.clickMaskClick(_1=&gt;{Obj}) @ testgui/sc/modules/ISC_Core.js:1871
                      [c]EventHandler.doHandleMouseDown(_1=&gt;[object MouseEvent],  _2=&gt;undef) @ testgui/sc/modules/ISC_Core.js:1433
                      [c]EventHandler.handleMouseDown(_1=&gt;[object MouseEvent]) @ testgui/sc/modules/ISC_Core.js:1428
                      [c]EventHandler.dispatch(_1=&gt;isc_c_EventHandler_handleMouseDown,  _2=&gt;[object MouseEvent]) @ testgui/sc/modules/ISC_Core.js:1722
                      anonymous([object MouseEvent]) @ testgui/sc/modules/ISC_Core.js:62
                      unnamed() @ 
                  
                  
                  com.smartgwt.client.core.JsObject$SGWT_WARN: 15:44:18.104:WARN:Log:TypeError: isc.Validator.getValidatorType is not a function
                      Canvas.validateField(_1=&gt;{Obj},  _2=&gt;[object Array],  _3=&gt;[object Date],  _4=&gt;{Obj},  _5=&gt;{Obj}) @ testgui/sc/modules/ISC_Core.js:3919
                      ListGrid.validateFieldValue(newValue=&gt;[object Date], oldValue=&gt;[object Date], record=&gt;{Obj}, field=&gt;{Obj}, rowNum=&gt;1, colNum=&gt;1, undefined=&gt;undef) @ testgui/sc/modules/ISC_Grids.js:2442
                      ListGrid.validateCellValue(rowNum=&gt;1, colNum=&gt;1, newValue=&gt;[object Date], oldValue=&gt;[object Date]) @ testgui/sc/modules/ISC_Grids.js:2437
                      ListGrid.validateRowValues(_1=&gt;{Obj},  _2=&gt;{Obj},  _3=&gt;1,  _4=&gt;[object Array]) @ testgui/sc/modules/ISC_Grids.js:2428
                      ListGrid.validateRecord(_1=&gt;1,  _2=&gt;undef) @ testgui/sc/modules/ISC_Grids.js:2425
                      ListGrid.validateRow(_1=&gt;1) @ testgui/sc/modules/ISC_Grids.js:2422
                      ListGrid.saveEdits(_1=&gt;&quot;click_outside&quot;,  _2=&gt;undef) @ testgui/sc/modules/ISC_Grids.js:2341
                      ListGrid._saveAndHideEditor(&quot;click_outside&quot;) @ testgui/sc/modules/ISC_Grids.js:2291
                      ListGrid.cellEditEnd(_1=&gt;&quot;click_outside&quot;) @ testgui/sc/modules/ISC_Grids.js:2256
                      ListGrid._handleClickOutsideEditor() @ testgui/sc/modules/ISC_Grids.js:2116
                      anonymous() @ testgui/sc/modules/ISC_Grids.js:1992
                      [c]Class.fireCallback(_1=&gt;anonymous) @ testgui/sc/modules/ISC_Core.js:325
                      EventHandler._clickMaskClick({Obj}) @ testgui/sc/modules/ISC_Core.js:1874
                      [c]EventHandler.clickMaskClick(_1=&gt;{Obj}) @ testgui/sc/modules/ISC_Core.js:1871
                      [c]EventHandler.doHandleMouseDown(_1=&gt;[object MouseEvent],  _2=&gt;undef) @ testgui/sc/modules/ISC_Core.js:1433
                      [c]EventHandler.handleMouseDown(_1=&gt;[object MouseEvent]) @ testgui/sc/modules/ISC_Core.js:1428
                      [c]EventHandler.dispatch(_1=&gt;isc_c_EventHandler_handleMouseDown,  _2=&gt;[object MouseEvent]) @ testgui/sc/modules/ISC_Core.js:1722
                      anonymous([object MouseEvent]) @ testgui/sc/modules/ISC_Core.js:62
                      unnamed() @ 
                  
                      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
                      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
                      at java.lang.reflect.Constructor.newInstance(Unknown Source)
                      at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
                      at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                      at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                      at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
                      at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
                      at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
                      at java.lang.Thread.run(Unknown Source)

                  Comment


                    #10
                    This results from loading mixed resources from two different builds. Every time you switch versions, you need to run a GWT compile and clear your browser cache.

                    Comment


                      #11
                      Same problem

                      I have the same problem with french translation (http://forums.smartclient.com/showth...p?t=27300).How did you solved the problem? Is it a bug on 2.5 version of smartgwt? Thanks in advance for your help

                      Comment

                      Working...
                      X