Announcement

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

    unexpected html element with showPrintPreview

    Hi Isomorphic,

    please see this modified builtinds sample:

    Code:
    package com.smartgwt.sample.client;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.Criteria;
    import com.smartgwt.client.data.DSCallback;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.ExpansionMode;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class BuiltInDS implements EntryPoint {
    
        /**
         * This is the entry point method.
         */
        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 animalsList = new ListGrid();
            animalsList.setDataSource(DataSource.get("animals"));
            animalsList.setWidth(500);
            animalsList.setHeight(350);
            animalsList.setAlternateRecordStyles(true);
            animalsList.setCanExpandRecords(true);
            animalsList.setAutoFetchData(false);
            animalsList.setExpansionMode(ExpansionMode.DETAIL_FIELD);
            animalsList.setDetailField("information");
            ListGridField nameField = new ListGridField("scientificName");
            ListGridField dietField = new ListGridField("diet");
            ListGridField commonNameField = new ListGridField("commonName");
            animalsList.setFields(nameField, dietField, commonNameField);
    
            animalsList.fetchData(new Criteria("scientificName", "newAnimal"), new DSCallback() {
    
                @Override
                public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                    // TODO Auto-generated method stub
                    animalsList.expandRecords(animalsList.getRecords());
    
                }
            });
            final VLayout mainLayout = new VLayout();
            mainLayout.setMembersMargin(5);
    
            IButton buttonPreview = new IButton();
            buttonPreview.setWidth(150);
            buttonPreview.setTitle("Show Print Preview");
    
            buttonPreview.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    final Window printProperties = new Window() {
                        {
                            setIsModal(true);
                            setWidth("50%");
                            setAutoCenter(true);
    
                        }
                    };
                    Canvas.showPrintPreview(new Object[] { mainLayout }, null, null, null, printProperties, null);
                }
            });
            HLayout hLayout = new HLayout();
            hLayout.setMembersMargin(5);
            hLayout.setMembers(buttonPdf, buttonPreview);
    
            mainLayout.addMembers(animalsList, hLayout);
    
            mainLayout.draw();
        }
    }
    animals.ds.xml:
    Code:
    <DataSource
        ID="animals"
        serverType="sql"
        tableName="animals"
        testFileName="animals.data.xml"
    >
        <fields>
            <field name="commonName"      title="Animal"             type="text"/>
            <field name="scientificName"  title="Scientific Name"    type="text"  primaryKey="true"  required="true"/>
            <field name="lifeSpan"        title="Life Span"          type="integer"/>
            <field name="status"          title="Endangered Status"  type="text">
                <valueMap>
                    <value>Threatened</value>
                    <value>Endangered</value>
                    <value>Not Endangered</value>
                    <value>Not currently listed</value>
                    <value>May become threatened</value>
                    <value>Protected</value>
                </valueMap>
            </field>
            <field name="diet"            title="Diet"               type="text"/>
            <field name="information"     title="Interesting Facts"  type="text"  length="1000" escapeHTML="true"/>
            <field name="picture"         title="Picture"            type="image" detail="true"
                   imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/"/>
        </fields>
    </DataSource>
    It seems, that escapeHTML in the ds.xml for the field "information" is not applied, or something other weird happens.

    To reproduce the issue:

    1. Start the sample, and go to the Developer Console.
    2. Go to the DataSources tab.
    3. select "animals"
    4. click "Add Record"
    5.set:
    Animal = newAnimal/or something else
    Scientific Name = newAnimal
    Life Span = 50/or something else
    Endangered Status = Threatened/or something else
    Diet= 34/or something else
    Interesting Facts = <yxc<yc<c bfbvfb rvvbb bf <-- this value is the important one
    6. safe the record
    7. reload the page

    8. Now You can see, that the Grid draws and expands the detail field "information" but nothing is inside. I would expect that "<yxc<yc<c bfbvfb rvvbb bf" is shown there.
    9. If You click now on "Show Print Preview" the Print Preview Window opens as expected, but still no value in the detail field.
    10. Now the weird thing: Right Click on the detail field and chose "inspect".
    11. In the DevTools (I'm using Google Chrome) in the "Elements" Tab you see the following if you expand the div with the style class "gridHover"
    Click image for larger version

Name:	gridHover.png
Views:	120
Size:	136.9 KB
ID:	259100

    So I dont know whats going on under the hood there, but this seems wrong to me.

    I think its something related to the hover and for that I could think about, applying a HoverCustomizer and override the hoverHTML method, BUT the method "setDetailField" on the ListGrid level allows only a String as parameter, so I have no chance to apply the HoverCustomizer. I could maybe configure the field and add it as hidden field then to the ListGrid. But that seems redundant and not wanted to me. So please have a look at this.

    SmartClient Version: v12.0p_2019-08-18/PowerEdition Deployment (built 2019-08-18)

    Tested Browsers:
    • Google Chrome 76.0.3809.100
    • Firefox Quantum 68.0.1
    Thanks in Advance,
    Kind Regards

    #2
    The issue with not escaping the detailField has been fixed. Please try the next nightly build, dated August 21.

    Regards
    Isomorphic Software

    Comment

    Working...
    X