protected void encodeTabs(FacesContext context, AccordionPanel acco) throws IOException {
    boolean dynamic = acco.isDynamic();
    String var = acco.getVar();
    List<String> activeIndexes = Arrays.asList(acco.getActiveIndex().split(","));
    boolean rtl = acco.getDir().equalsIgnoreCase("rtl");

    if (var == null) {
      int i = 0;

      for (UIComponent child : acco.getChildren()) {
        if (child.isRendered() && child instanceof Tab) {
          boolean active = activeIndexes.indexOf(Integer.toString(i)) != -1;

          encodeTab(context, acco, (Tab) child, active, dynamic, rtl);

          i++;
        }
      }
    } else {
      int dataCount = acco.getRowCount();
      Tab tab = (Tab) acco.getChildren().get(0);

      for (int i = 0; i < dataCount; i++) {
        acco.setIndex(i);
        boolean active = activeIndexes.indexOf(Integer.toString(i)) != -1;

        encodeTab(context, acco, tab, active, dynamic, rtl);
      }

      acco.setIndex(-1);
    }
  }
  protected void encodeStateHolder(FacesContext context, AccordionPanel accordionPanel)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String clientId = accordionPanel.getClientId(context);
    String stateHolderId = clientId + "_active";

    writer.startElement("input", null);
    writer.writeAttribute("type", "hidden", null);
    writer.writeAttribute("id", stateHolderId, null);
    writer.writeAttribute("name", stateHolderId, null);
    writer.writeAttribute("value", accordionPanel.getActiveIndex(), null);
    writer.writeAttribute("autocomplete", "off", null);
    writer.endElement("input");
  }