Announcement

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

    SmartGWT and SmartClient TabSet differences - default tab in SmartGWT

    Hi Isomorphic,

    using v12.1p_2022-08-10 (and also older 12.0p) it seems that TabSet in SmartGWT generates a default Tab with ID isc_x (x is a number).
    I'm creating Tabs from a DataSource call. The tabSelected handler then lazily builds the pane from the tab ID.
    The tabSelected handler also fires for this default tab, which is not wanted. Strangely enough, this default tab is not visible in my application, but the handler fires nevertheless.

    SmartClient TabSet does not generate this Tab and can draw without any Tab. Here (v12.1p_2023-03-07) the good behavior from SmartClient:
    Code:
    isc.TabSet.create({
        ID: "tabSet",
        width: "100%",
        height: "100%",
        tabSelected: function(tabNum, tabPane, ID, tab, name) {
            isc.logWarn("Name: " + name + ", ID: " + ID + ", Title: " + tab.title);
        }
    });
    
    isc.IButton.create({
        ID: "myButton",
        title: "Load Tabs",
        click: "this.loadTabs()",
        loadTabs: function() {
            countryDS.fetchData({
                fieldName: "countryName",
                operator: "lessThan",
                value: "I"
            }, function(dsResponse, data) {
                for (let i = 0; i < data.length; i++) {
                    tabSet.addTab({
                        "name": "name_" + i,
                        "title": data[i].countryName
                    });
                }
    
            });
        }
    });
    
    isc.VLayout.create({
        members: [tabSet, myButton],
        membersMargin: 5,
        height: 300,
        width: 700
    });
    Does this already help you to narrow down the problem in SmartGWT?

    Thank you & Best regards
    Blama

    #2
    Hi Isomorphic,

    perhaps disregard this for now unless you already have an idea what's happening. I tried recreating in BuiltInDS (using v12.1p_2022-08-10), but did not succeed to far.
    This is my code, which is close to what I have in my application, and it's not showing the problem.

    Best regards
    Blama

    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.DSCallback;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.Overflow;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.types.TabBarControls;
    import com.smartgwt.client.util.BooleanCallback;
    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.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.tab.Tab;
    import com.smartgwt.client.widgets.tab.TabSet;
    import com.smartgwt.client.widgets.tab.events.CloseClickHandler;
    import com.smartgwt.client.widgets.tab.events.TabCloseClickEvent;
    import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
    import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
    
    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("Problem generated default Tab for TabSet" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final TabSet tabset = new TabSet();
            tabset.setPaneContainerProperties(new Canvas() {
                {
                    setOverflow(Overflow.AUTO); // Is default, just here to show that this is on purpose.
                }
            });
            tabset.setHeight100();
            tabset.setWidth100();
            tabset.setCanCloseTabs(true);
            tabset.addTabSelectedHandler(new TabSelectedHandler() {
                @Override
                public void onTabSelected(TabSelectedEvent event) {
                    SC.logWarn(
                            "Selected ID: " + (event.getID() != null ? event.getID() : "") + ", Name: " + (event.getName() != null ? event.getName() : "")
                                    + ", Title: " + (event.getTab().getTitle() != null ? event.getTab().getTitle() : ""));
                }
            });
    
            tabset.addCloseClickHandler(new CloseClickHandler() {
                @Override
                public void onCloseClick(TabCloseClickEvent event) {
                    event.cancel();
                    SC.logWarn("Closing ID: " + (event.getTab().getID() != null ? event.getTab().getID() : "") + ", Name: "
                            + (event.getTab().getName() != null ? event.getTab().getName() : "") + ", Title: "
                            + (event.getTab().getTitle() != null ? event.getTab().getTitle() : ""));
                    SC.ask("Close Tab?", new BooleanCallback() {
                        @Override
                        public void execute(Boolean value) {
                            if (value != null && value) {
                                tabset.removeTab(event.getTab());
                            }
                        }
                    });
                }
            });
    
            IButton addButton = new IButton();
            addButton.setTitle("Add person");
    
            IButton renameButton = new IButton();
            renameButton.setTitle("Rename person");
    
            HLayout spaceHL = new HLayout();
            spaceHL.setWidth(10);
    
            tabset.setTabBarControls(addButton, spaceHL, renameButton, TabBarControls.TAB_SCROLLER, TabBarControls.TAB_PICKER);
    
            IButton loadTabsBtn = new IButton("Load Tabs", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    DataSource.get("employees").fetchData(new AdvancedCriteria("reportsTo", OperatorId.EQUALS, 4), new DSCallback() {
                        @Override
                        public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                            for (final Record r : dsResponse.getData()) {
                                Tab tab = new Tab();
                                tab.setTitle(r.getAttributeAsString("Name"));
                                tab.setName("EMPLOYEE_" + r.getAttributeAsString("EmployeeId"));
                                tab.setID("EMPLOYEE_" + r.getAttributeAsString("EmployeeId"));
                                tabset.addTab(tab);
                            }
                        }
                    }, new DSRequest() {
                        {
                            setSortBy(new SortSpecifier[] { new SortSpecifier("EmployeeId", SortDirection.ASCENDING) });
                        }
                    });
                }
            });
    
            VLayout vLayout = new VLayout() {
                {
                    addMembers(tabset, loadTabsBtn);
                }
            };
            w.addItem(vLayout);
            w.show();
        }
    }

    Comment


      #3
      Hi Isomorphic,

      please disregard the whole post. Without going into further detail: It was an annoying coding mistake.

      Thank you & Best regards
      Blama

      Comment

      Working...
      X