Announcement

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

    Many warnings in Developer Console when using FormItem.setReadOnlyWhen in an editable ListGrid

    Hi Isomorphic,

    please see this testcase (v11.1p_2018-06-21), which clutters the Developer Console log with messages like:
    Code:
    [ERROR] [builtinds] - 17:44:56.341:MUP5:WARN:AutoTest:Locator string:item[0][Class="ListGrid"] matching by index gave[ListGrid ID:isc_ListGrid_2]. Reliability cannot be guaranteed for matching by index if the underlying application undergoes any changes.
    This is related to the two setReadOnlyWhen().

    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.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.FormItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridEditorContext;
    import com.smartgwt.client.widgets.grid.ListGridEditorCustomizer;
    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("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("Many warnings in Developer Console" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid animalsGrid = new ListGrid(DataSource.get("animals"));
            animalsGrid.setEditorCustomizer(new ListGridEditorCustomizer() {
                @Override
                public FormItem getEditor(ListGridEditorContext context) {
                    if ("commonName".equals(context.getEditField().getName())) {
                        TextItem ti = new TextItem();
                        ti.setReadOnlyWhen(new AdvancedCriteria(new Criterion("commonName", OperatorId.LESS_OR_EQUAL, "H")));
                        return ti;
                    }
                    return null;
                }
            });
    
            animalsGrid.setHeight100();
            animalsGrid.setAutoFetchData(false);
            animalsGrid.setCanEdit(true);
    
            ListGridField scientificName = new ListGridField("scientificName");
            scientificName.setCanEdit(false);
            ListGridField commonName = new ListGridField("commonName");
            ListGridField lifeSpan = new ListGridField("lifeSpan");
            TextItem ti = new TextItem();
            ti.setReadOnlyWhen(new AdvancedCriteria(new Criterion("commonName", OperatorId.LESS_OR_EQUAL, "H")));
            lifeSpan.setEditorProperties(ti);
    
            ListGridField status = new ListGridField("status");
    
            animalsGrid.setFields(scientificName, commonName, lifeSpan, status);
            animalsGrid.setSort(new SortSpecifier[] { new SortSpecifier(scientificName.getName(), SortDirection.ASCENDING) });
            animalsGrid.fetchData();
            w.addItem(animalsGrid);
            w.show();
        }
    }
    Best regards
    Blama

    #2
    After review we will be making a couple of changes to suppress certain warnings when AutoTest locators are used internally. However, *When rules are not supported on ListGrid edit forms. Ability to edit can be determined by LG.canEditCell. Conditional required can be handled by a conditional or custom validator. We will update the documentation as well.

    Comment

    Working...
    X