コード例 #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 encodeTab(
      FacesContext context,
      AccordionPanel accordionPanel,
      Tab tab,
      boolean active,
      boolean dynamic,
      boolean rtl)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();

    String headerClass =
        active ? AccordionPanel.ACTIVE_TAB_HEADER_CLASS : AccordionPanel.TAB_HEADER_CLASS;
    headerClass = tab.isDisabled() ? headerClass + " ui-state-disabled" : headerClass;
    headerClass =
        tab.getTitleStyleClass() == null
            ? headerClass
            : headerClass + " " + tab.getTitleStyleClass();
    String iconClass =
        active
            ? AccordionPanel.ACTIVE_TAB_HEADER_ICON_CLASS
            : (rtl
                ? AccordionPanel.TAB_HEADER_ICON_RTL_CLASS
                : AccordionPanel.TAB_HEADER_ICON_CLASS);
    String contentClass =
        active
            ? AccordionPanel.ACTIVE_TAB_CONTENT_CLASS
            : AccordionPanel.INACTIVE_TAB_CONTENT_CLASS;
    UIComponent titleFacet = tab.getFacet("title");
    String title = tab.getTitle();
    String tabindex = tab.isDisabled() ? "-1" : accordionPanel.getTabindex();

    // header container
    writer.startElement("div", null);
    writer.writeAttribute("class", headerClass, null);
    writer.writeAttribute("role", "tab", null);
    writer.writeAttribute("aria-expanded", String.valueOf(active), null);
    writer.writeAttribute("aria-selected", String.valueOf(active), null);
    writer.writeAttribute("aria-label", tab.getAriaLabel(), null);
    writer.writeAttribute("tabindex", tabindex, null);
    if (tab.getTitleStyle() != null) writer.writeAttribute("style", tab.getTitleStyle(), null);
    if (tab.getTitletip() != null) writer.writeAttribute("title", tab.getTitletip(), null);

    // icon
    writer.startElement("span", null);
    writer.writeAttribute("class", iconClass, null);
    writer.endElement("span");

    if (titleFacet != null) titleFacet.encodeAll(context);
    else if (title != null) writer.writeText(title, null);
    else writer.write("&nbsp;");

    writer.endElement("div");

    // content
    writer.startElement("div", null);
    writer.writeAttribute("id", tab.getClientId(context), null);
    writer.writeAttribute("class", contentClass, null);
    writer.writeAttribute("role", "tabpanel", null);
    writer.writeAttribute("aria-hidden", String.valueOf(!active), null);

    if (dynamic) {
      if (active) {
        tab.encodeAll(context);
        tab.setLoaded(true);
      }
    } else tab.encodeAll(context);

    writer.endElement("div");
  }
コード例 #3
0
  public void wygeneruj(HashMap lista) throws Exception {
    FacesContext facesCtx = FacesContext.getCurrentInstance();
    ELContext elContext = facesCtx.getELContext();
    ExpressionFactory ef = ExpressionFactory.newInstance();

    akordeon = new AccordionPanel();
    // robienie glownej oprawy
    Set nazwyew = lista.keySet();
    Iterator it;
    it = nazwyew.iterator();
    int i = 0;
    while (it.hasNext()) {
      String nazwapj = (String) it.next();
      Tab tab = new Tab();
      tab.setId("tabek" + i);
      tab.setTitle("ewidencja: " + nazwapj);

      DataTable dataTable = new DataTable();
      dataTable.setId("tablica" + i);
      // dataTable.setResizableColumns(true);
      dataTable.setVar("var");
      dataTable.setValue(lista.get(nazwapj));
      dataTable.setStyle("width: 1000px;");
      // tak trzeba opisac kazda kolumne :)
      ArrayList<String> opisykolumn = new ArrayList<>();
      opisykolumn.addAll(EVatViewPola.getOpispol());
      Iterator itx;
      itx = opisykolumn.iterator();
      while (itx.hasNext()) {
        String wstawka = (String) itx.next();
        Column column = new Column();
        column.setHeaderText(wstawka);
        final String binding = "#{var." + wstawka + "}";
        ValueExpression ve = ef.createValueExpression(elContext, binding, String.class);
        HtmlOutputText ot = new HtmlOutputText();
        ot.setValueExpression("value", ve);
        switch (wstawka) {
          case "kontr":
            column.setWidth("350");
            break;
          case "id":
            column.setWidth("50");
            break;
          case "netto":
            ot.setStyle("float: right;");
            NumberConverter numx = new NumberConverter();
            numx.setMaxFractionDigits(2);
            numx.setMinFractionDigits(2);
            ot.setConverter(numx);
          case "vat":
            ot.setStyle("float: right;");
            NumberConverter numy = new NumberConverter();
            numy.setMaxFractionDigits(2);
            numy.setLocale(new Locale("PL"));
            numy.setGroupingUsed(true);
            ot.setConverter(numy);
        }
        column.getChildren().add(ot);
        dataTable.getChildren().add(column);
      }
      Separator sep = new Separator();
      CommandButton button = new CommandButton();
      button.setValue("PobierzPdf");
      button.setType("button");
      button.setId("przyciskpdf" + i);
      FacesContext context = FacesContext.getCurrentInstance();
      MethodExpression actionListener =
          context
              .getApplication()
              .getExpressionFactory()
              .createMethodExpression(
                  context.getELContext(),
                  "#{pdf.drukujewidencje('zakup')}",
                  null,
                  new Class[] {ActionEvent.class});
      button.addActionListener(new MethodExpressionActionListener(actionListener));
      //            MethodExpression methodExpressionX =
      // context.getApplication().getExpressionFactory().createMethodExpression(
      //            context.getELContext(), "#{pdf.drukujewidencje('"+nazwapj+"')}", null, new
      // Class[] {});
      //            button.setActionExpression(methodExpressionX);
      String nowanazwa;
      if (nazwapj.contains("sprzedaż")) {
        nowanazwa = nazwapj.substring(0, nazwapj.length() - 1);
      } else {
        nowanazwa = nazwapj;
      }
      String tablican =
          "PrimeFaces.ab({source:'form:przyciskpdf"
              + i
              + "',onsuccess:function(data,status,xhr){wydrukewidencje('"
              + wpisView.getPodatnikWpisu()
              + "','"
              + nowanazwa
              + "');;}});return false;";
      button.setOnclick(tablican);
      tab.getChildren().add(dataTable);
      tab.getChildren().add(sep);
      tab.getChildren().add(button);
      akordeon.getChildren().add(tab);

      i++;
    }

    // generowanie podsumowania
    List<EVatwpisSuma> suma2 = new ArrayList<>();
    suma2.addAll(sumaewidencji.values());
    Tab tab = new Tab();
    tab.setId("tabekdsuma");
    tab.setTitle("podsumowanie ewidencji");
    DataTable dataTable = new DataTable();
    dataTable.setId("tablicasuma");
    dataTable.setResizableColumns(true);
    dataTable.setVar("var");
    dataTable.setValue(suma2);
    dataTable.setStyle("width: 1000px;");
    List<String> opisykolumny = new ArrayList<>();
    opisykolumny.add("ewidencja");
    opisykolumny.add("netto");
    opisykolumny.add("vat");
    Iterator ity = opisykolumny.iterator();
    while (ity.hasNext()) {
      String wstawka = (String) ity.next();
      Column column = new Column();
      column.setHeaderText(wstawka);
      HtmlOutputText ot = new HtmlOutputText();
      if (!wstawka.equals("ewidencja")) {
        ot.setStyle("float: right;");
        NumberConverter numberconv = new NumberConverter();
        numberconv.setLocale(new Locale("PL"));
        numberconv.setMinFractionDigits(2);
        numberconv.setMaxFractionDigits(2);
        column.setWidth("200");
        ot.setConverter(numberconv);
      }
      final String binding = "#{var." + wstawka + "}";
      ValueExpression ve = ef.createValueExpression(elContext, binding, String.class);
      ot.setValueExpression("value", ve);
      column.getChildren().add(ot);
      dataTable.getChildren().add(column);
    }
    tab.getChildren().add(dataTable);
    akordeon.getChildren().add(tab);
  }