@Override
  protected void doDecode(FacesContext context, UIComponent component) {
    super.doDecode(context, component);

    UITab tab = (UITab) component;
    UITabPanel panel = tab.getPane();

    Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();

    if (AjaxRendererUtils.isAjaxRequest(context)
        && tab.getSwitchTypeOrDefault().equals(UISwitchablePanel.AJAX_METHOD)
        && requestParameterMap.get(tab.getClientId(context)) != null) {

      // add toggle panel itself to rendered list of components
      AjaxRendererUtils.addRegionByName(context, panel, panel.getId());
      AjaxRendererUtils.addRegionsFromComponent(tab, context);

      AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
      Set<String> toProcess = ajaxContext.getAjaxAreasToProcess();
      if (toProcess == null) {
        toProcess = new HashSet<String>(1);
        ajaxContext.setAjaxAreasToProcess(toProcess);
      }
      toProcess.add(panel.getClientId(context));

      ajaxContext.addAreasToProcessFromComponent(context, tab);
    }
  }
  public void encodeChildren(FacesContext context, UIComponent component) throws IOException {

    UITab tab = (UITab) component;
    if (shouldRenderTab(tab)) {
      if ((tab.getChildren() != null) && (tab.getChildren().size() > 0)) {
        renderChildren(context, component);
      } else {
        ResponseWriter out = context.getResponseWriter();
        out.write("&#160;");
      }
    }
  }
  public String getTabDisplay(FacesContext context, UITab tab) {
    if (!tab.isActive()) {
      return "display: none;";
    }

    return "";
  }
 protected boolean shouldRenderTab(UITab tab) {
   String method = tab.getSwitchTypeOrDefault();
   return (tab.isActive() || !tab.isDisabled() && UISwitchablePanel.CLIENT_METHOD.equals(method));
 }