Announcement

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

    TabSet.disableTab (tab) fails silently if tab is not added first

    Problem:
    I called TabSet.disableTab (tab) for a tab that I did not add to the TabSet yet, and I got no error.
    I would expect this to fail, and if not, at least log something...
    What do you think?

    1. the *complete* SmartGWT or SmartClient version from the lower left-hand corner of the Developer Console (see FAQ for how to open Developer Console), for example, \"v8.2p_2012-04-18/PowerEdition Deployment\"
    SmartClient Version: v10.0p_2015-07-18/LGPL Development Only (built 2015-07-18)

    2. browser(s) and version(s) involved
    FF 19
    GWT 2.5

    3. for a server-side problem, the *complete* logs generated during processing of the failing request (do *not* trim to just the error message)

    4. for any problem processing a server response, the actual response as shown in the RPC tab in the Developer Console

    5. if there is a JavaScript error, the stack trace logged in the Developer Console (see FAQ)

    6. sample code if applicable
    Code:
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.tab.TabSet;
    import com.smartgwt.client.widgets.tab.Tab;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.google.gwt.core.client.EntryPoint;
    
    public class TestDisableTab implements EntryPoint {
    
      /**
       * The EntryPoint interface
       * SmartClient Version: v10.0p_2015-07-18/LGPL Development Only (built 2015-07-18)
       *   tabSet.disableTab (tab) fails silently for a Tab not yet added
       */
      public void onModuleLoad () {
    
        // TabSet
        final TabSet tabSet = new TabSet();
        tabSet.setWidth (600);
        tabSet.setHeight (400);
    
        // Tab #1
        {
          final TextItem nameItem = new TextItem ();
          nameItem.setTitle ("Name");
    
          final DynamicForm form = new DynamicForm ();
          form.setFields (nameItem);
          
          final Tab tab = new Tab ("Tab #1");
          tab.setPane (form);
          tabSet.addTab (tab);
        }
        
        // Tab #2, disabled before being added to the TabSet
        final Tab tab2;
        {
          final TextItem nameItem = new TextItem ();
          nameItem.setTitle ("Name");
    
          final DynamicForm form = new DynamicForm ();
          form.setFields (nameItem);
          
          final Tab tab = new Tab ("Tab #1");
          tab.setPane (form);
          // tabSet.addTab (tab);
          tabSet.disableTab (tab); // <------------ I would expect this to fail
          tabSet.addTab (tab);
          
          tab2 = tab;
        }
        
        final IButton button = new IButton ();
        button.setTitle ("Enable Tab #2");
        button.addClickHandler (new ClickHandler () {
          boolean enableFlag = true;
          public void onClick (ClickEvent event) {
            if (enableFlag) {
              tabSet.enableTab (tab2);
              button.setTitle ("Disable Tab #2");
            }
            else {
              tabSet.disableTab (tab2);
              button.setTitle ("Enable Tab #2");
            }
            enableFlag = !enableFlag;
          }
        });
        
        // layout
        final VLayout layout = new VLayout ();
        layout.addMember (tabSet);
        layout.addMember (button);
        layout.draw ();
      }
    }

    #2
    Following your suggestion, we have made a change to add a logWarn() for this case, just saying "disableTab() ignored, no such tab '[index]'". You'll find it applied in the next nightly build.

    Thanks

    Comment


      #3
      This seems to have broken us. I now see those warnings logged and all our tabs are disabled where before they were not.

      Comment


        #4
        Isomorphic:
        I am confirming that I see the warning you added.
        Using SmartClient Version: v10.0p_2015-07-31/LGPL Development Only (built 2015-07-31
        Sample output
        Code:
        00:02:27.100 [ERROR] 09:57:36.642:WARN:TabSet:isc_TabSet_1:disableTab() ignored, no such tab 'isc_Tab_3'com.smartgwt.client.core.JsObject$SGWT_WARN: 09:57:36.642:WARN:TabSet:isc_TabSet_1:disableTab() ignored, no such tab 'isc_Tab_3'
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
         at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
         at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
         at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
         at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
         at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
         at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
         at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:299)
         at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
         at com.smartgwt.client.widgets.tab.TabSet.disableTab(TabSet.java)
         at org.shortpasta.smartgwttest.portal.client.layout.TestDisableTab.onModuleLoad(TestDisableTab.java:90)
         at org.shortpasta.smartgwttest.portal.client.Portal.onModuleLoad(Portal.java:205)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:497)
         at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
         at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
         at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
         at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
         at java.lang.Thread.run(Thread.java:745)
        stonebranch1:
        Using the code sample above, I do not see what you are reporting.

        Comment


          #5
          Hi Isomorphic,

          Originally posted by stonebranch1 View Post
          This seems to have broken us. I now see those warnings logged and all our tabs are disabled where before they were not.
          Same here. A start-disabled tab that I enable in the code stays disabled and I get the following warning in the Developer Console:
          Code:
          19:19:15.762:XRP9:WARN:TabSet:isc_TabSet_0:disableTab() ignored, no such tab 'undefined'
          Using v10.0p_2015-07-30.

          Best regards
          Blama

          Comment


            #6
            Ours was working on: SmartClient Version: SNAPSHOT_v10.1d_2015-07-27/Pro Deployment (built 2015-07-27)

            And is broken on: SmartClient Version: SNAPSHOT_v10.1d_2015-07-30/Pro Deployment (built 2015-07-30)

            Same log message as Blama posted

            Comment


              #7
              I changed my initial test to start the tab disabled via tab.setDisabled (true). It starts disabled. Then I click the button to enable it, and it works as expected with the following:

              1. the *complete* SmartGWT or SmartClient version from the lower left-hand corner of the Developer Console (see FAQ for how to open Developer Console), for example, \"v8.2p_2012-04-18/PowerEdition Deployment\"
              SmartClient Version: v10.0p_2015-07-18/LGPL Development Only (built 2015-07-18)

              2. browser(s) and version(s) involved
              FF 19

              6. sample code if applicable
              Code:
              public class TestDisableTab implements EntryPoint {
              
                public void onModuleLoad () {
              
                  // TabSet
                  final TabSet tabSet = new TabSet();
                  tabSet.setWidth (600);
                  tabSet.setHeight (400);
              
                  // Tab #1
                  {
                    final TextItem nameItem = new TextItem ();
                    nameItem.setTitle ("Name1");
              
                    final DynamicForm form = new DynamicForm ();
                    form.setFields (nameItem);
                    
                    final Tab tab = new Tab ("Tab #1");
                    tab.setPane (form);
                    tabSet.addTab (tab);
                  }
                  
                  // Tab #2, disabled before being added to the TabSet
                  final Tab tab2;
                  {
                    final TextItem nameItem = new TextItem ();
                    nameItem.setTitle ("Name2");
              
                    final DynamicForm form = new DynamicForm ();
                    form.setFields (nameItem);
                    
                    final Tab tab = new Tab ("Tab #2");
                    tab.setDisabled (true); // <-------- stonebranch1/blama test: start the tab disabled and enable later
                    tab.setPane (form);
                    tabSet.addTab (tab);
                    // tabSet.disableTab (tab); // <------------ I would expect this to fail when called before addTab ()
                    // tabSet.addTab (tab);
                    
                    tab2 = tab;
                  }
                  
                  final IButton button = new IButton ();
                  button.setTitle ("Enable Tab #2");
                  button.addClickHandler (new ClickHandler () {
                    boolean enableFlag = true;
                    public void onClick (ClickEvent event) {
                      if (enableFlag) {
                        tabSet.enableTab (tab2);
                        button.setTitle ("Disable Tab #2");
                      }
                      else {
                        tabSet.disableTab (tab2);
                        button.setTitle ("Enable Tab #2");
                      }
                      enableFlag = !enableFlag;
                    }
                  });
                  
                  // layout
                  final VLayout layout = new VLayout ();
                  layout.addMember (tabSet);
                  layout.addMember (button);
                  layout.draw ();
                }
              }

              Comment


                #8
                We see the problem - some ways of identifying tabs when calling enableTab() or disableTab() (specifically, by name or ID) were broken by this change. We'll have this fixed for tomorrow's build, sorry about the confusion.

                Comment

                Working...
                X