Announcement

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

    12.0p ValidationContext.setResultingValue issue on client side when editor is TextAreaItem(?) or Hilite(?)

    Hi Isomorphic,

    please see the attached BuiltInDS-based testcase (v12.0p_2018-12-13) and video.
    It seems, there is some issue with ListGrid-display of the cacheSync values after successful ListGrid edit (the last edit is the one that is not displayed accordingly).
    I assume this is not related to validationContext.setResultingValue(), but I saw it with this when I tested it in my application.
    I assume this is related somehow to either TextAreaItem and/or Hilite and also a timing issue, as it does not happen always (see the video).

    The video taken using FF26 and SuperDevMode. It happend in my application using current Chrome and SuperDevMode.

    Click image for larger version

Name:	Problem with cacheSync.gif
Views:	147
Size:	358.0 KB
ID:	256213

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Hilite;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    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.fields.TextAreaItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        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();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("25%");
            w.setHeight("45%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("TITLE" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid supplyItemGrid = new ListGrid(DataSource.get("supplyItem"));
            supplyItemGrid.setHilites(new Hilite[] { new MandatoryAndNotVisibleHilite() });
    
            supplyItemGrid.setHeight100();
            supplyItemGrid.setWidth100();
            supplyItemGrid.setCanEdit(true);
            supplyItemGrid.setAutoFetchData(false);
    
            ListGridField itemID = new ListGridField("itemID");
            ListGridField itemName = new ListGridField("itemName");
            ListGridField sku = new ListGridField("SKU");
            sku.setEditorProperties(new TextAreaItem());
            ListGridField category = new ListGridField("category");
    
            supplyItemGrid.setFields(itemID, itemName, sku, category);
            supplyItemGrid.setSort(new SortSpecifier[] { new SortSpecifier(itemName.getName(), SortDirection.ASCENDING) });
            supplyItemGrid.fetchData(new AdvancedCriteria(new Criterion(itemName.getName(), OperatorId.STARTS_WITH, "A")));
            w.addItem(supplyItemGrid);
            w.show();
        }
    
        private class MandatoryAndNotVisibleHilite extends Hilite {
            public MandatoryAndNotVisibleHilite() {
                super();
                setFieldNames(new String[] { "SKU", "category" });
                setBackgroundColor("#CD5C5C");
                setCriteria(new AdvancedCriteria(OperatorId.AND,
                        new Criterion[] { new Criterion("category", OperatorId.EQUALS, "General Office Products") }));
            }
        }
    }
    TestValidator.java:
    Code:
    package com.smartgwt.sample.server.listener;
    
    import java.util.Map;
    
    import javax.servlet.http.HttpServletRequest;
    
    import com.isomorphic.datasource.DSResponse;
    import com.isomorphic.datasource.DataSource;
    import com.isomorphic.datasource.ValidationContext;
    import com.isomorphic.datasource.Validator;
    import com.isomorphic.log.Logger;
    
    public class TestValidator {
        Logger log = new Logger(DSResponse.class.getName());
    
        public boolean condition(Object value, Validator validator, String fieldName, @SuppressWarnings("rawtypes") Map record, DataSource ds,
                HttpServletRequest httpServletRequest, ValidationContext validationContext) throws Exception {
            log.info("TestValidator called");
            validationContext.setResultingValue("123456");
            return true;
        }
    }
    supplyItem.ds.xml:
    Code:
    <DataSource
        ID="supplyItem"
        serverType="sql"
        tableName="supplyItem"
        titleField="itemName"
        testFileName="/examples/shared/ds/test_data/supplyItem.data.xml"
        dbImportFileName="/examples/shared/ds/test_data/supplyItemLarge.data.xml"
    >
        <fields>
            <field name="itemID"      type="sequence" hidden="true"       primaryKey="true"/>
            <field name="itemName"    type="text"     title="Item"        length="128"       required="true" />
            <field name="SKU"         type="text"     title="SKU"         length="10"        required="true">
                        <validators>
                            <validator type="serverCustom" dependentFields="inStock, unitCost">
                                <serverObject lookupStyle="new" className="com.smartgwt.sample.server.listener.TestValidator" />
                                <errorMessage>$errorMessage</errorMessage>
                            </validator>
                        </validators>
            </field>
            <field name="description" type="text"     title="Description" length="2000"/>
            <field name="category"    type="text"     title="Category"    length="128"       required="true"
                   foreignKey="supplyCategory.categoryName"/>
            <field name="units"       type="enum"     title="Units"       length="5">
                <valueMap>
                    <value>Roll</value>
                    <value>Ea</value>
                    <value>Pkt</value>
                    <value>Set</value>
                    <value>Tube</value>
                    <value>Pad</value>
                    <value>Ream</value>
                    <value>Tin</value>
                    <value>Bag</value>
                    <value>Ctn</value>
                    <value>Box</value>
                </valueMap>
            </field>
            <field name="unitCost"    type="float"    title="Unit Cost"   required="true">
                <validators>
                    <validator type="floatRange" min="0" errorMessage="Please enter a valid (positive) cost"/>
                    <validator type="floatPrecision" precision="2" errorMessage="The maximum allowed precision is 2"/>
                </validators>
            </field>
            <field name="inStock"   type="boolean"  title="In Stock"/>
            <field name="nextShipment"  type="date" title="Next Shipment"/>
        </fields>
    </DataSource>
    Best regards
    Blama

    #2
    Hi Isomorphic,

    I could also reproduce without the supplyItemGrid.setHilites()-call, but it took ~30 edits in FF26 and ~5 edits in Chromium 71.0.3578.80 the 1st time and ~30 edits the 2nd time.

    Best regards
    Blama

    Comment


      #3
      We've been able to reproduce this issue in a reliable manner locally and have checked in a change which addresses it for us.
      The change will be present in the next nightly builds (Jan 4 or above), 12.0 and 12.1 branches.

      If it persists for you, please let us know

      Thanks
      Isomorphic Software

      Comment

      Working...
      X