コード例 #1
0
  @Override
  public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    AccordionPanel acco = (AccordionPanel) component;

    if (acco.isContentLoadRequest(context)) {
      String var = acco.getVar();
      String clientId = acco.getClientId(context);

      if (var == null) {
        String tabClientId = params.get(clientId + "_newTab");
        Tab tabToLoad = acco.findTab(tabClientId);
        tabToLoad.encodeAll(context);
        tabToLoad.setLoaded(true);
      } else {
        int index = Integer.parseInt(params.get(clientId + "_tabindex"));
        acco.setIndex(index);
        acco.getChildren().get(0).encodeAll(context);
        acco.setIndex(-1);
      }
    } else {
      encodeMarkup(context, acco);
      encodeScript(context, acco);
    }
  }
コード例 #2
0
  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);
    }
  }