Announcement

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

    Saving UTF-8 data in SGWT

    Hello there,

    Using SmartClient Version: v10.0p_2015-03-13/PowerEdition Deployment (built 2015-03-13) with Firefox 26
    I have a listgrid where i type in UTF-8 character and then when i try to save it to my database the data is saved as ?????????. I have put
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    in my html file. In the developer Console when I look into the RPC tab. I see the DSREquest is being sent in UTF-8 format but in the DSResponse and in my db I get this ??????.
    In my database table I have defined the col type as nvarchar which is the requirement for saving utf-8. but the problem is smartgwt is not sending the text in proper format into the db. can somebody help me to get this correct.

    In the console I see everything correct

    === 2015-04-22 12:45:25,929 [9-27] INFO PoolManager - [builtinApplication.importExcelDS_add] SmartClient pooling started for 'SQLServer' objects
    === 2015-04-22 12:45:25,929 [9-27] DEBUG PoolableSQLConnectionFactory - [builtinApplication.importExcelDS_add] Initializing SQL config for 'SQLServer' from system config - using DriverManager: net.sourceforge.jtds.jdbc.Driver
    === 2015-04-22 12:45:25,929 [9-27] DEBUG PoolableSQLConnectionFactory - [builtinApplication.importExcelDS_add] net.sourceforge.jtds.jdbc.Driver lookup successful
    === 2015-04-22 12:45:25,929 [9-27] DEBUG PoolableSQLConnectionFactory - [builtinApplication.importExcelDS_add] DriverManager fetching connection for SQLServer via jdbc url jdbc:jtds:sqlserver://localhost:1433;DatabaseName=dbilling;useUnicode=true;characterEncoding=UTF-8;sendStringAsUnicode=true;User=teoit;Password=seop
    === 2015-04-22 12:45:25,929 [9-27] DEBUG PoolableSQLConnectionFactory - [builtinApplication.importExcelDS_add] Passing JDBC URL only to getConnection

    === 2015-04-22 12:45:25,999 [9-27] INFO SQLDriver - [builtinApplication.importExcelDS_add] Executing SQL update on 'SQLServer': INSERT INTO sales (available, productMth, productName, productYr) VALUES (NULL, NULL, 'به آسا اماکن ۸ ٪ - ۴ لیتر - محلول ضد عفونی کننده', NULL)

    The only thing that is missing is the N which should have been there before the utf-8 string. like so

    INSERT INTO sales (available, productMth, productName, productYr) VALUES (NULL, NULL, N'به آسا اماکن ۸ ٪ - ۴ لیتر - محلول ضد عفونی کننده', NULL)

    cheers
    Zolf
    Last edited by zaj; 22 Apr 2015, 00:20.

    #2
    Did you change the project to UTF-8 in Propeties -> Resource -> Text File Encoding?

    Comment


      #3
      See the Internationalization overview, and for the N prefix, the DataSourceField.type docs.

      Comment


        #4
        Thanks for the feedbacks.
        Yes i have changed the project.
        Can you please post the link to that N prefix docs

        Comment


          #5
          Again, see DataSourceField.type. In the FieldType enum, there is a type "ntext". Can't miss it.

          Comment


            #6
            Thanks working as expected
            Last edited by zaj; 24 Apr 2015, 20:36.

            Comment


              #7
              Originally posted by Isomorphic View Post
              Again, see DataSourceField.type. In the FieldType enum, there is a type "ntext". Can't miss it.
              Actually I have problem with UTF-8 right now.
              When using Basic Connector example in showcase "č" , "ć" and "đ" are working but in my app they don't.

              So the problem comes when I want to add text that contains "č" , "ć" and "đ". Result is always "?" instead of those three letters.
              UTF-8 in HTML is included and I tried with type="text" and "ntext". Same result. I get "??đ" instead of "čćđ".
              Letters "šž" are working normally.

              Any suggestions?

              SmartClient Version: v10.0p_2015-03-31/EVAL Deployment

              ds.xml:
              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              
              <DataSource 
              	ID="razdjel" 
              	dataFormat="iscServer" 
              	serverType="sql" 
              	dbName="Mysql" 
              	schema="zupanijskiproracun" 
              	tableName="razdjel" 
              >
              	<fields>
              	  <field sqlType="tinyint" sqlLength="3" name="id_razdjel" type="integer" title="ID" primaryKey="true"/>
                        <field sqlType="varchar" sqlLength="255" name="naziv_razdjel" type="ntext" required="true" title="Razdjel"/>
                        <field sqlType="varchar" sqlLength="255" name="user" length="255" type="ntext" title="Korisnik" foreignKey="users.user_name"/>
              	  </fields>
              </DataSource>
              code:
              Code:
              DataSource ds = DataSource.getDataSource("razdjel");
              listGrid = new ListGrid();
              listGrid.setWidth(600);
              listGrid.setHeight(300);
              listGrid.setDataSource(ds);
              listGrid.setAutoFetchData(true);
              listGrid.setLayoutAlign(Alignment.CENTER);
              listGrid.setLeaveScrollbarGap(false);
              listGrid.setCanEdit(true);
              listGrid.setShowFilterEditor(true);
              listGrid.setEditEvent(ListGridEditEvent.DOUBLECLICK);
              listGrid.setCanRemoveRecords(true);
              listGrid.setAlternateRecordStyles(true);
              listGrid.setCanResizeFields(true);
              
              ListGridField lgf1 = new ListGridField("id_razdjel", "ID", 50);
              ListGridField lgf2 = new ListGridField("naziv_razdjel", "Razdjel", 470);
              ListGridField lgf3 = new ListGridField("user", "Korisnik", 50);
              
              listGrid.setFields(lgf1, lgf2, lgf3);
              
              newButton = new IButton("New");
              newButton.setLayoutAlign(Alignment.CENTER);
                  newButton.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent event) {
                           listGrid.startEditingNew();
                          }
                      });
              Last edited by JohnDoe92; 18 May 2015, 11:04.

              Comment


                #8
                Take a look at the Internationalization overview in the docs. If you've missed any of the steps there, you could end up with the characters being garbled before they reach the DB or server.

                Then, if you need more help, you will need to post both server logs and the contents of the RPC tab in the Developer Console.

                Comment

                Working...
                X