Announcement

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

    #16
    After reviewing this, we have factored out the encoding handling in processRequest() such that the currently documented approach (that you used) will now work correctly.

    This change will be included in the March 7, 2015 stable build.

    Comment


      #17
      That's April 7, not March - sorry about that.

      Comment


        #18
        Hi Isomorphic,

        I retested with today's nightly and no code changes and it is working as expected - thanks a lot.
        The only minor thing left is the wrong output in the log (also in BuiltInDS). See posts #9 and #10 for this.

        BuiltInDS.java:
        Code:
        package com.smartgwt.sample.client;
        
        import com.google.gwt.core.client.EntryPoint;
        import com.smartgwt.client.core.KeyIdentifier;
        import com.smartgwt.client.data.DSRequest;
        import com.smartgwt.client.data.DataSource;
        import com.smartgwt.client.types.ExportFormat;
        import com.smartgwt.client.types.SelectionStyle;
        import com.smartgwt.client.types.SortArrow;
        import com.smartgwt.client.util.PageKeyHandler;
        import com.smartgwt.client.util.Page;
        import com.smartgwt.client.util.SC;
        import com.smartgwt.client.widgets.IButton;
        import com.smartgwt.client.widgets.events.ClickEvent;
        import com.smartgwt.client.widgets.events.ClickHandler;
        import com.smartgwt.client.widgets.grid.ListGrid;
        import com.smartgwt.client.widgets.grid.ListGridField;
        import com.smartgwt.client.widgets.grid.ListGridRecord;
        import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
        import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
        import com.smartgwt.client.widgets.layout.VStack;
        
        public class BuiltInDS implements EntryPoint {
        	private ListGrid boundList;
        	private IButton exportBtn;
        
        	public void onModuleLoad() {
        		KeyIdentifier debugKey = new KeyIdentifier();
        		debugKey.setCtrlKey(true);
        		debugKey.setKeyName("D");
        
        		Page.registerKey(debugKey, new PageKeyHandler() {
        			public void execute(String keyName) {
        				SC.showConsole();
        			}
        		});
        
        		ListGrid grid = new ListGrid();
        		grid.setLeft(20);
        		grid.setTop(75);
        		grid.setWidth(130);
        		grid.setLeaveScrollbarGap(false);
        		grid.setShowSortArrow(SortArrow.NONE);
        		grid.setCanSort(false);
        		grid.setFields(new ListGridField("dsTitle", "Select a DataSource"));
        		grid.setData(new ListGridRecord[] { new DSRecord("Animals", "animals"), new DSRecord("Office Supplies", "supplyItem"),
        				new DSRecord("Employees", "employees") });
        		grid.setSelectionType(SelectionStyle.SINGLE);
        		grid.addRecordClickHandler(new RecordClickHandler() {
        			public void onRecordClick(RecordClickEvent event) {
        				DSRecord record = (DSRecord) event.getRecord();
        				bindComponents(record.getDsName());
        			}
        		});
        
        		grid.draw();
        
        		VStack vStack = new VStack();
        		vStack.setLeft(175);
        		vStack.setTop(75);
        		vStack.setWidth("70%");
        		vStack.setMembersMargin(20);
        
        		boundList = new ListGrid();
        		boundList.setHeight(400);
        		boundList.setShowFilterEditor(true);
        		boundList.setCanEdit(true);
        		boundList.setCanPickFields(true);
        
        		vStack.addMember(boundList);
        
        		exportBtn = new IButton("Export");
        		exportBtn.addClickHandler(new ClickHandler() {
        			public void onClick(ClickEvent event) {
        				DSRequest requestProperties = new DSRequest() {
        					{
        						setExportAs(ExportFormat.OOXML);
        						setExportFilename("testexport");
        					}
        				};
        				boundList.exportClientData(requestProperties);
        			}
        		});
        		vStack.addMember(exportBtn);
        		vStack.draw();
        	}
        
        	private void bindComponents(String dsName) {
        		DataSource ds = DataSource.get(dsName);
        		boundList.setDataSource(ds);
        		boundList.fetchData();
        	}
        }
        Introduce an Umlaut in the data and export to see it.

        Best regards,
        Blama

        Comment


          #19
          Good to hear the export is working.

          In terms of log output showing the correct characters: the entire SC/SGWT pipeline from browser to the various JVM APIs uses UTF-8, and assuming your are using the new log4j configuration files (with the explicit UTF-8 encoding in the log4j config file as discussed earlier in this thread), the UTF-8 pipeline extends all the way to the logs.

          But - in order for the console output to appear properly, the console has to support UTF-8. On windows, this means you have to use the proper codepage _and_ a font that has the proper characters.

          Assuming we are talking about your Windows 8.1 setup, and you're using the platform standard cmd.exe to start the server, you need to run this command before starting your app server:

          Code:
          chcp 65001
          And you also need to change the console font to a TrueType font like "Lucida Console". To do this, click on the C:\ icon at top left of the console, select "Properties" and in the Font tab, pick the "Lucida Console" font. Note that any output in the console prior to this change will not transcode correctly, but any future output will.

          More (extremely extensive) information here: http://stackoverflow.com/questions/1...-cmd-exe-using

          We will be updating the relevant docs to point to this approach. This approach works in our testing, but please let us know how this works out for you!

          Comment


            #20
            Hello Isomorphic,

            thank you for your suggestions. After being assured there is no bug I searched for the solution. Unfortunately your advice does not apply for me as I'm starting Tomcat from inside Eclipse.

            After changing all places loosely related to encoding to UTF-8, I found the location that fixed it for me. It is in the Eclipse settings under General-Workspace-Textfile encoding, which seems unrelated. But setting this fixes the display of umlauts for me.

            Other places that might also be relevant:
            • Apache Software Foundation\Tomcat 7.0\lib\log4j.properties -> log4j.appender.CONSOLE.Encoding = UTF-8
            • Eclipse server manager view -> Double-click server -> Open launch configuration -> Common -> Encoding
            • Server.xml: <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8" />
            • Font in the console as suggested by you: General -> Apperance -> Colors and Fonts -> Debug -> Console font: For me, the default of "Courier New" is working

            Thanks for your help & Best regards,
            Blama
            Last edited by Blama; 9 Apr 2015, 08:07.

            Comment


              #21
              Thanks for sharing that. It looks like one more place is the "Launch Configuration" for the application server. There is a tab here called "Common" with an encoding section where the default platform encoding is selected by default. For some platforms this may not be set to UTF-8. If so, that should be modified as well.

              UTF-8 should really be what everyone uses for everything at this point for full compatibility. But there is a lot of inertia with backcompat etc. Hopefully at some point soon all tools will default to UTF-8 and this gotcha goes away.

              Comment

              Working...