Announcement

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

    ValuesManager warnings in DEV console

    Hi Isomorphic,

    please take a look at this test case.
    I have found warnings in the DEV console that may not be correct.

    If you click on the "Warnings 1" button, you will get a warning in the DEV console:
    Code:
    WARN:DynamicForm:isc_DynamicForm1_1:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
    This warning does not appear if you click on the "Warnings 2" button. The logic behind is exactly the same as for the 1st case so INHO there should be no warning in this case.

    If you click on the "Warnings 1" button, then close that window then click on "Warnings 2" button, you will get 4 warnings of this kind:
    Code:
    :Log:ID 'isc_TextItem_2' for object '[TextItem ID:isc_TextItem_2 name:commonName]' collides with the ID of an existing object. This can occur when the specified ID for a new SmartClient Canvas is the same as a native attribute of 'window', or another variable already assigned in global scope. The global reference to this object will be replaced. Consider instead using a different ID to avoid this collision altogether, especially if the colliding ID is a native attribute of window.  Replacing such objects often has serious and unintended consequences. In this case, the current value of window['isc_TextItem_2'] is:
    But this might be okay since I didn't set the ID for DynamicForms even though I'm not entirely sure if the warning should appear or not but I would say that it shouldn't appear.

    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.types.OperatorId;
    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.DynamicForm;
    import com.smartgwt.client.widgets.form.ValuesManager;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS extends VLayout implements EntryPoint {
        private IButton recreateBtn1;
        private IButton recreateBtn2;
    
        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();
                }
            });
    
            setWidth100();
            setHeight100();
    
            recreateBtn1 = new IButton("Warnings 1");
            recreateBtn1.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new Warnings1Window().show();
                }
            });
            addMember(recreateBtn1);
    
            recreateBtn2 = new IButton("Warnings 2");
            recreateBtn2.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new Warnings2Window().show();
                }
            });
            addMember(recreateBtn2);
    
            draw();
        }
    
        private class Warnings1Window extends Window {
            public Warnings1Window() {
                setWidth(400);
                setHeight(300);
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                ValuesManager valuesManager = new ValuesManager();
                valuesManager.setDataSource(DataSource.get("animals"));
                MainVLayout mainVLayout = new MainVLayout(valuesManager);
                addItem(mainVLayout);
                valuesManager.fetchData(new AdvancedCriteria(new Criterion("scientificName", OperatorId.EQUALS, "Myrmecophaga tridactyla")));
            }
        }
    
        private class Warnings2Window extends Window {
            public Warnings2Window() {
                setWidth(400);
                setHeight(300);
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setTitle("img- vs object-tag issue" + getTitle());
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                ValuesManager valuesManager2 = new ValuesManager();
                valuesManager2.setDataSource(DataSource.get("animals"));
                VLayout vLayout = new VLayout();
                DynamicForm dF = new DynamicForm();
                valuesManager2.addMember(dF);
                FormItem commonName = new FormItem("commonName");
                dF.setFields(commonName);
                vLayout.setMembers(dF);
                addItem(vLayout);
                valuesManager2.fetchData(new AdvancedCriteria(new Criterion("scientificName", OperatorId.EQUALS, "Myrmecophaga tridactyla")));
    
            }
        }
    
    }
    MainVLayout.java
    Code:
    package com.smartgwt.sample.client;
    
    import com.smartgwt.client.widgets.form.ValuesManager;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    class MainVLayout extends VLayout {
        MainVLayout(ValuesManager valuesManager) {
            DynamicForm1 dynamicForm1 = new DynamicForm1();
            valuesManager.addMember(dynamicForm1);
            setMembers(dynamicForm1);
        }
    }
    DynamicForm1.java
    Code:
    package com.smartgwt.sample.client;
    
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    
    class DynamicForm1 extends DynamicForm {
        DynamicForm1() {
            FormItem commonName = new FormItem("commonName");
            setFields(commonName);
        }
    }
    Best,
    Pavo
    Last edited by pavo123; 9th Apr 2020, 05:23.

    #2
    If you explicitly set the DataSource on both the DynamicForm as well as on the ValuesManager, you should not see these warnings.
    (This limitation may go away in the future. We also have a developer looking into this issue to determine why specifying the DataSource in both places is necessary to avoid this warning)

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      that solves the problem, thank you! If this limitation go away in the future, please let me know here.

      Best,
      Pavo

      Comment

      Working...
      X