Announcement

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

    DataSource title and international characters

    Hi,

    I use SmartGWTee 2.3. I have a dataSource:

    <?xml version="1.0" encoding="UTF-8"?>
    <DataSource ID="intezmeny" dataFormat="iscServer" serverType="sql" dbName="care3" tableName="intezmeny">
    <fields>
    <field name="id" type="sequence" hidden="true" primaryKey="true"/>
    <field name="nev" type="text" required="true" length="50" title="Név"/>
    <field name="created_at" type="datetime" hidden="false" title="Árvíztűrő tükörfúrógép"/>
    <field name="updated_at" type="datetime" hidden="false" enabled="false"/>
    </fields>
    <title>Intézmény</title>
    <titleField>nev</titleField>
    <pluralTitle>Intézmény</pluralTitle>
    <dataSourceVersion>1</dataSourceVersion>
    <generatedBy>SC_SNAPSHOT-2010-08-03/EVAL Deployment 2010-08-03</generatedBy>
    </DataSource>

    I use hungarian characters in the title. The problem is, the title look like this in the application:
    N�v : �rv�zt?r? t�k�rf�r�g�p :

    The DataSource file coded by UTF-8. The data from my database look good in the application.

    What is the problem?

    #2
    The JVM may not have the right charset, or the .html bootstrap file may be being served with the wrong charset (check the HTTP headers with Firebug), or the .ds.xml file may not actually have been properly saved in UTF-8 format (check your text editor).

    Comment


      #3
      Thank You the quick answer!

      I use utf-8 everywhere. I checked the DataSource file in Notepad++. It coded UTF-8. The bootstrep .html is utf-8 too. The other text in the app are all good (from the database or the java code).

      I don't know the carset of the JVM. Where can I check or set it?

      Comment


        #4
        http://lmgtfy.com/?q=jvm+charset ;)

        Comment


          #5
          Thanks for the tip :-)!
          I have windows7, so i run a command prompt and give the

          java -Dfile.encoding=UTF-8

          command.
          Then make an environment variable

          JAVA_TOOL_OPTION = -Dfile.encoding=UTF-8

          and restart the system.

          The result is the same.

          Made widgets in my builtinds.java (the modified SWGT sample app) with "árvíztűrő tükörfúrógép" title. The widgets from builtinds.java are good, but the titles from .ds.xml are wrong.

          Comment


            #6
            This is the set of steps that everyone else reports as working. All we can suggest is to double-check everything from the file format to whether the Java encoding has been successfully set.

            Comment


              #7
              I can not solve my previous problem. I can not figure what is wrong because all of the file is coded by utf-8.

              But now I found another problem (maybe an international bug).

              final KeyUpHandler belepesKeyUpHandler = new KeyUpHandler(){
              @Override
              public void onKeyUp(KeyUpEvent event) {
              String s = event.getKeyName();
              if (event.getKeyName().equals("Enter")) {
              fetchUser((String) tiFelhasznaloNev.getValue(), (String) piJelszo.getValue());
              }
              }
              };
              tiFelhasznaloNev.addKeyUpHandler(belepesKeyUpHandler);

              If I write a ,í' or ,Í' character in the tiFelhasznaloNev (TextItem) i get an error.
              The reason of the error: In this situation the event.getKeyName return with null. The other hungarian characters are handled well.

              Comment


                #8
                The KeyDownHandler don't recognize ,í', but recognize ,Í', and the event.getKeyName() return with null.

                Comment


                  #9
                  Originally posted by Isomorphic
                  This is the set of steps that everyone else reports as working. All we can suggest is to double-check everything from the file format to whether the Java encoding has been successfully set.
                  Actually, I have had the same problem, and could only solve it by introducing a manual workaround. See here:

                  http://forums.smartclient.com/showthread.php?t=9071

                  Comment


                    #10
                    What you mention in that other thread is some kind of Jetty bug. Are you running Jetty inside Eclipse and have you made any special changes to the Jetty configuration? Because others that are using Eclipse are not reporting an issue with i18n characters, and GWT documentation does not list special steps required for i18n to work with Jetty.

                    About getKeyName() - this is expected to be null because only certain keys (like Enter) have a special "key name". Use the character value for other keys.

                    Comment


                      #11
                      Originally posted by Isomorphic
                      What you mention in that other thread is some kind of Jetty bug.
                      That was only my best guess; I was not able to fully debug this. All I know is that while the DS XML file is UTF8, the data returned by the call to the DataSourceLoader servlet was ISO1.

                      Are you running Jetty inside Eclipse and have you made any special changes to the Jetty configuration?
                      Yes and no.

                      Because others that are using Eclipse are not reporting an issue with i18n characters, and GWT documentation does not list special steps required for i18n to work with Jetty.
                      Yes, it buffles me, too. And I did checked (runtime) the JVM settings, which were correct. And still, the returned DS description was clearly not UTF8, without the workaround.

                      * * *

                      Whatever the case, this solves it:

                      Code:
                      public class SgweetDataSourceLoader extends DataSourceLoader {
                      
                      private static final long serialVersionUID = 1L;
                      	
                      @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                        response.setCharacterEncoding("UTF-8");
                        super.doGet(request, response);
                      }
                      	
                      @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException ,IOException {
                        response.setCharacterEncoding("UTF-8");
                        super.doPost(request, response);
                      }
                      }

                      Comment


                        #12
                        Wow, apparently they document that they do this (override the JVM charset and force ISO-1), see here (starting from "there is a default charset").

                        Apparently we'll need to add a flag to force them to respect the JVM charset..

                        Comment


                          #13
                          This was my guess , but it seemed so stupid that did not even look it up in the Jetty docs.

                          * * *

                          Anyway, until this is fixed, the workaround mentioned above takes care of any previous misconfiguration.

                          Comment


                            #14
                            I use Jetty inside Eclipse. I didn't changed any settings.

                            The getKeyName return the uppercased character (not null) if i use letter keys. (Except ,í".) One plus check (event.getKeyName() != null) is a solution now because I handle only the 'enter', but it could be a problem in other situation.

                            What do You mean: "Use the character value for other keys." The KeyUpEvent, KeyDownEvent hasn't Value, CharValue or something like this property or getter for character value.

                            Comment


                              #15
                              Thanks Csillag for the solution. I tried it, but i make samething wrong. I am new in JAVA, GWT, SmartGWT and web development :-( Sorry for this.

                              I made a new SgweetDataSourceLoader class in com.myapp.server package.
                              Code:
                              package com.care.server;
                              
                              import java.io.IOException;
                              
                              import javax.servlet.ServletException;
                              import javax.servlet.http.HttpServletRequest;
                              import javax.servlet.http.HttpServletResponse;
                              
                              import com.isomorphic.servlet.DataSourceLoader;
                              
                              public class SgweetDataSourceLoader extends DataSourceLoader {
                              
                              	private static final long serialVersionUID = 1L;
                              		
                              	@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                              	  response.setCharacterEncoding("UTF-8");
                              	  super.doGet(request, response);
                              	}
                              		
                              	@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException ,IOException {
                              	  response.setCharacterEncoding("UTF-8");
                              	  super.doPost(request, response);
                              	}
                              }
                              I changed the
                              Code:
                                  <script src="care/sc/DataSourceLoader?dataSource=jogosultsagok"></script>
                              line to this:
                              Code:
                                  <script src="care/sc/SgweetDataSourceLoader?dataSource=jogosultsagok"></script>
                              Now in my entrypoint class this code dosn't work (worked before):
                              Code:
                                  	dsJogosultsagok = DataSource.get("jogosultsagok");
                              The result is null.

                              What is wrong, or what is missing?

                              Comment

                              Working...
                              X