@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);
    }
  }
 /**
  * @return JavaScript eventString. Rebuild on every call, since can be in loop ( as in dataTable )
  *     with different parameters.
  */
 public String getEventString() {
   StringBuffer buildOnEvent = new StringBuffer();
   String onsubmit = getOnsubmit();
   // Insert script to call before submit ajax request.
   if (null != onsubmit) {
     buildOnEvent.append(onsubmit).append(";");
   }
   buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(), getEvent(), true));
   String script = buildOnEvent.toString();
   return script;
 }
  public void testBroadCast() {
    ScrollableGridViewEvent event = new ScrollEvent(table, 20, 30);
    event.setAttribute("attr", "value0");
    table.broadcast(event);
    assertEquals("value0", table.getAttributes().get("attr"));

    AjaxEvent ajaxEvent = new AjaxEvent(table);
    String id = AjaxRendererUtils.getAbsoluteId(table);
    table.broadcast(ajaxEvent);
    assertTrue(ajaxContext.getAjaxAreasToRender().contains(id));

    SortListener1 sortListener = new SortListener1();
    table.setSortListener(sortListener);
    table.broadcast(new SortEvent(table, "0", 20, 30));
    assertTrue(sortListener.triggered);
  }
 /**
  * Looks up the parent naming container for the component source of the action event, and reset
  * components recursively within this container.
  *
  * @since 5.9.1
  */
 public void resetComponentsFor(ActionEvent event) {
   UIComponent component = event.getComponent();
   if (component == null) {
     return;
   }
   String baseCompId = getBaseComponentId();
   if (baseCompId != null) {
     FacesContext ctx = FacesContext.getCurrentInstance();
     UIComponent target = RendererUtils.getInstance().findComponentFor(component, baseCompId);
     if (target != null) {
       baseCompId = AjaxRendererUtils.getAbsoluteId(target);
     }
     UIComponent anchor = ctx.getViewRoot().findComponent(baseCompId);
     resetComponentResursive(anchor);
   } else {
     log.error("No base component id given => cannot reset " + "components state.");
   }
 }