Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

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

$
0
0
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 ();
  }
}


Viewing all articles
Browse latest Browse all 4756

Trending Articles