@Override
  public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    super.encodeEnd(context, component);

    if (!(component.isRendered())) {
      return;
    }
    ResponseWriter writer = context.getResponseWriter();
    newLine(writer);

    UIDojoAccordionContainer c = (UIDojoAccordionContainer) component;

    if (isTrackClientSelection()) {
      String id = c.getClientId(context) + _SELECTION;
      String selectedTab = c.getSelectedTab();
      if (selectedTab == null) {
        selectedTab = "";
      }
      writer.startElement("input", component); // this is for the uistate $NON-NLS-1$
      writer.writeAttribute("id", id, null); // $NON-NLS-1$
      writer.writeAttribute("name", id, null); // $NON-NLS-1$
      writer.writeAttribute("type", "hidden", null); // $NON-NLS-1$ $NON-NLS-2$
      writer.writeAttribute("value", selectedTab, null); // $NON-NLS-1$
      writer.endElement("input"); // $NON-NLS-1$
    }
  }
  @Override
  protected void initDojoAttributes(
      FacesContext context, FacesDojoComponent dojoComponent, Map<String, String> attrs)
      throws IOException {
    super.initDojoAttributes(context, dojoComponent, attrs);
    if (dojoComponent instanceof UIDojoAccordionContainer) {
      UIDojoAccordionContainer c = (UIDojoAccordionContainer) dojoComponent;

      DojoRendererUtil.addDojoHtmlAttributes(
          attrs, "duration", c.getDuration(), 250); // $NON-NLS-1$
    }
  }
 @Override
 public void decode(FacesContext context, UIComponent component) {
   if (isTrackClientSelection()) {
     String fieldId = component.getClientId(context) + _SELECTION;
     String selectedTab =
         (String) context.getExternalContext().getRequestParameterMap().get(fieldId);
     if (StringUtil.isNotEmpty(selectedTab)) {
       ((UIDojoAccordionContainer) component).setSelectedTab(selectedTab);
     }
   }
 }