Announcement

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

    Exception on DataSource.load with force reload

    Hi Isomorphic,

    I have a Datasource, only relevant for the Admin and of course with declarative security, I don't need very often and I don't want to load on startup via the DataSourceLoader call from my HTML.
    So I load it when I need it. but the forced reload of it fails or at least throws an exception in the Developer Console. Now I could not load it if it is already there, but I think it is an issue anyway, because there might be legitimate reasons to reload a DS.

    On "Reload" click (OK):
    WARN:DataSource:DataSource(s) already loaded: employees
    Use forceReload to reload such DataSources

    On "Force Reload" click (not OK):
    WARN:Log:ID 'employees' for object '[DataSource ID:employees]' 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['employees'] is:

    DataSource{testFileName: "/examples/shared/ds/test_data/employees...."[48],
    titleField: "Name",
    allowAdvancedCriteria: true,
    tableCode: "a6744ab162eb640344ffc18c778b303d",
    xmlns: "lmscompany/ds",
    recordName: "employee",
    serverType: "sql",
    useAnsiJoins: true,
    operationBindings: Array[1],
    ID: "employees",
    fields: Obj,
    canQueueRequests: true,
    name: "employees",
    }
    BuiltInDS.java (tested with v10.1p_2017-08-20):
    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.DataSource;
    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.layout.VLayout;
    
    public class BuiltInDS extends VLayout implements EntryPoint {
        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();
                }
            });
    
            setWidth100();
            setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new MyWindow().show();
                }
            });
            addMember(recreateBtn);
            new MyWindow().show();
            draw();
        }
    
        private class MyWindow extends Window {
            public MyWindow() {
                setWidth("95%");
                setHeight("95%");
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                setTitle("DataSource force reload problem" + getTitle());
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                IButton reloadButton = new IButton("Reload");
                reloadButton.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        DataSource.load("employees", null, false);
                    }
                });
                addItem(reloadButton);
    
                IButton reloadForceButton = new IButton("Force Reload");
                reloadForceButton.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        DataSource.load("employees", null, true);
                    }
                });
                addItem(reloadForceButton);
            }
        }
    }
    Best regards
    Blama

    #2
    To properly do a forceReload and avoid this warning, destroy() the old DataSource first (and any components using it).

    Comment


      #3
      Hi Isomorphic,

      you are correct, it is working like this. But what is the purpose of the forceReload parameter then?

      Best regards
      Blama

      Comment


        #4
        It causes clobbering of the existing DataSource rather than just avoiding the duplicate load.

        Comment

        Working...
        X