Announcement

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

    setLineBreakStyle broken?

    SmartClient Version: v8.3p_2013-05-15/PowerEdition Deployment (built 2013-05-15)

    With v3.1, it appears that this call generates incorrect line endings (Was not a problem in v3.0). This code:
    Code:
    dsRequest.setExportAs(ExportFormat.CSV);
    dsRequest.setLineBreakStyle("unix");
    results in lines ending in CR - it should be LF. This code:
    Code:
    dsRequest.setExportAs(ExportFormat.CSV);
    dsRequest.setLineBreakStyle("dos");
    results in lines ending in CRCRLF - it should be CRLF.

    The documentation for the setLineBreakStyle API refers to further documentation on the allowed values for lineBreakStyle, which I could not find (LineBreakStyle class??). Can you point me to the documentation on the allowed values?
    Code:
    public void setLineBreakStyle(java.lang.String lineBreakStyle)
    
        The style of line-breaks to use in the exported output. 
        See LineBreakStyle for more information.
    We are attempting to migrate our application to version 3.1 and this issue has broken all of our export to CSV functionality.

    #2
    Additional info

    We are using grid.exportClientData(dsRequest) not grid.exportData(dsRequest).

    As I said, this works in v3.0 but not in v3.1.

    I did see that the exportData API works in the showcase.

    Thanks,

    Matt

    Comment


      #3
      There was such a bug, but it was fixed April 15th. Most likely, your server-side .jars are not as new as the version you indicated, or you have two copies in the classpath and the old ones are still being used.

      Comment


        #4
        More info

        Is it possible for the developer console to report the wrong version? That's where I got the version number in my original report...

        I've double-checked and I am running the 5/15 version. I have also replicated the issue in the Showcase sample app.

        My class path only points to the version from 5/15.

        Console output from Showcase startup:
        Code:
        === 2013-05-15 19:30:22,038 [main] INFO  ConfigLoader - Attempting to load server.properties from CLASSPATH
        === 2013-05-15 19:30:22,049 [main] INFO  ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/F:/smartgwtpower-3.1p/samples/showcase/war/WEB-INF/classes/server.properties
        === 2013-05-15 19:30:22,059 [main] INFO  Logger - Logging system started.
        === 2013-05-15 19:30:22,060 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework (v8.3p_2013-05-15/PowerEdition Deployment 2013-05-15) - Initialization Complete
        === 2013-05-15 19:30:22,064 [main] INFO  ISCInit - Auto-detected webRoot - using: F:\smartgwtpower-3.1p\samples\showcase\war
        === 2013-05-15 19:30:22,088 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework initialization called from com.isomorphic.base.Base
        See the attached screen shot from the Developer Console as well.

        My modified ExcelExportSample.java source from the showcase:
        Code:
        /*
         * Isomorphic SmartGWT web presentation layer
         * Copyright 2000 and beyond Isomorphic Software, Inc.
         *
         * OWNERSHIP NOTICE
         * Isomorphic Software owns and reserves all rights not expressly granted in this source code,
         * including all intellectual property rights to the structure, sequence, and format of this code
         * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein.
         *
         *  If you have any questions, please email <sourcecode@isomorphic.com>.
         *
         *  This entire comment must accompany any portion of Isomorphic Software source code that is
         *  copied or moved from this file.
         */
        
        package com.smartgwt.sample.showcase.client.dataintegration.java.others;
        
        import com.smartgwt.client.data.DataSource;
        import com.smartgwt.client.data.DSRequest;
        import com.smartgwt.client.widgets.Canvas;
        import com.smartgwt.client.widgets.IButton;
        import com.smartgwt.client.widgets.layout.VLayout;
        import com.smartgwt.client.widgets.layout.HLayout;
        import com.smartgwt.client.widgets.events.ClickHandler;
        import com.smartgwt.client.widgets.form.DynamicForm;
        import com.smartgwt.client.widgets.form.fields.SelectItem;
        import com.smartgwt.client.widgets.form.fields.BooleanItem;
        import com.smartgwt.client.widgets.form.fields.FormItem;
        import com.smartgwt.client.widgets.grid.ListGrid;
        import com.smartgwt.client.widgets.grid.ListGridField;
        import com.smartgwt.client.types.Autofit;
        import com.smartgwt.client.types.Alignment;
        import com.smartgwt.client.types.ExportDisplay;
        import com.smartgwt.client.types.ExportFormat;
        import com.smartgwt.client.util.EnumUtil;
        import com.smartgwt.sample.showcase.client.PanelFactory;
        import com.smartgwt.sample.showcase.client.ShowcasePanel;
        
        import java.util.LinkedHashMap;
        
        
        public class ExcelExportSample extends ShowcasePanel {
            private static final String DESCRIPTION = "<p>It's now easy to export data from a DataSource or from DataboundComponents, such as <b>ListGrid</b>, <b>TreeGrid</b> and <b>TileGrid</b>. In the example below, choose an Export-Format from the select-list, decide whether to download the results or view them in a window using the checkbox and click the Export button. " +
                    "Because exporting to JSON is allowed only via server-side custom-code or via an OperationBinding, choosing JSON from the select-item issues the export using the operationId set up in the DataSource but still respects the \"Show in Window\" checkbox.</p>" +
                    "<p>Try changing the filters and sort-order on the grid to see that the exported data is filtered and sorted according to criteria applied to the grid.</p>";
        
            public static class Factory implements PanelFactory {
        
                private String id;
        
                public Canvas create() {
                    ExcelExportSample panel = new ExcelExportSample();
                    id = panel.getID();
                    return panel;
                }
        
                public String getID() {
                    return id;
                }
        
                public String getDescription() {
                    return DESCRIPTION;
                }
            }
        
            protected boolean isTopIntro() {
                return true;
            }
        
            public Canvas getViewPanel() {
        
                DataSource worldDSExport = DataSource.get("worldDSExport");
        
                final ListGrid countryList = new ListGrid();
                countryList.setWidth(500);
                countryList.setAlternateRecordStyles(true);
                countryList.setDataSource(worldDSExport);
                countryList.setAutoFetchData(true);
        
                ListGridField countryName = new ListGridField("countryName", "Country");
                ListGridField capital = new ListGridField("capital", "Capital");
                ListGridField continent = new ListGridField("continent", "Continent");
        
                countryList.setFields(countryName, capital, continent);
                countryList.setAutoFitData(Autofit.VERTICAL);
                countryList.setShowFilterEditor(true);
                countryList.setAutoFitMaxRecords(10);
        
                final DynamicForm exportForm = new DynamicForm();
                exportForm.setWidth(300);
        
                SelectItem exportTypeItem = new SelectItem("exportType", "Export Type");
                exportTypeItem.setWidth("*");
                exportTypeItem.setDefaultToFirstOption(true);
        
                LinkedHashMap valueMap = new LinkedHashMap();
                valueMap.put("csv", "CSV (Excel)");
                valueMap.put("xml", "XML");
                valueMap.put("json", "JSON");
                valueMap.put("xls", "XLS (Excel97)");
                valueMap.put("ooxml", "XLSX (Excel2007/OOXML)");
        
                exportTypeItem.setValueMap(valueMap);
        
                BooleanItem showInWindowItem = new BooleanItem();
                showInWindowItem.setName("showInWindow");
                showInWindowItem.setTitle("Show in Window");
                showInWindowItem.setAlign(Alignment.LEFT);
        
                exportForm.setItems(exportTypeItem, showInWindowItem);
        
                IButton exportButton = new IButton("Export");
                exportButton.addClickHandler(new ClickHandler() {
                    public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
                        String exportAs = (String) exportForm.getField("exportType").getValue();
        
                        FormItem item = exportForm.getField("showInWindow");
                        boolean showInWindow =  item.getValue() == null ? false : (Boolean) item.getValue();
        
                        if(exportAs.equals("json")) {
                            // JSON exports are server-side only, so use the OperationBinding on the DataSource
                            DSRequest dsRequestProperties = new DSRequest();
                            dsRequestProperties.setOperationId("customJSONExport");
                            dsRequestProperties.setExportDisplay(showInWindow ? ExportDisplay.WINDOW : ExportDisplay.DOWNLOAD);
        
                            countryList.exportData(dsRequestProperties);
                        } else {
                           // exportAs is either XML or CSV, which we can do with requestProperties
                            DSRequest dsRequestProperties = new DSRequest();
                            dsRequestProperties.setExportAs((ExportFormat)EnumUtil.getEnum(ExportFormat.values(), exportAs));
                            dsRequestProperties.setExportDisplay(showInWindow ? ExportDisplay.WINDOW : ExportDisplay.DOWNLOAD);
        
                            dsRequestProperties.setLineBreakStyle("unix");
                            countryList.exportClientData(dsRequestProperties);
                        }
                    }
                });
        
                VLayout layout = new VLayout(15);
                layout.setAutoHeight();
        
                HLayout formLayout = new HLayout(15);
                formLayout.addMember(exportForm);
                formLayout.addMember(exportButton);
                layout.addMember(formLayout);
        
                layout.addMember(countryList);
        
                return layout;
        
            }
        
            public String getIntro() {
                return DESCRIPTION;
            }
        }
        Please investigate. Thanks!
        Attached Files

        Comment


          #5
          Developer console reported correct version. Back on 4/15 we fixed different bug.

          Your reported issue is fixed now. You could get next nightly build and try it out.

          Comment


            #6
            Not fixed...

            I re-tested this in the showcase (as shown above) using the build from 05/16. Or will this not be there till the 05/17 build?

            The line endings are still CR when set to "unix" and they should be LF. See http://en.wikipedia.org/wiki/Newline

            Version reported in developer console "SmartClient Version: v8.3p_2013-05-16/PowerEdition Deployment (built 2013-05-16)"
            Last edited by mattcecile; 16 May 2013, 06:50.

            Comment


              #7
              Right, these changes will not be in today's build. You should wait till next one.

              And yes, line endings were messed up for unix/mac, now they are changed to LF for "unix", CR for "mac" and CR/LF for "dos".

              Comment


                #8
                Still not working...

                From developer console I am running:
                SmartClient Version: v8.3p_2013-05-17/PowerEdition Deployment (built 2013-05-17)

                I still get only CR when specifying "unix" as the line break style. This is in my project and using the Showcase example given above.

                Matt

                Comment


                  #9
                  05/19 build has the fix.

                  My fault it wasn't in previous builds, apologies.

                  Comment

                  Working...
                  X