public static MethodExpression createMethodExpression(
     String el, Class returnType, Class[] paramTypes) {
   FacesContext context = FacesContext.getCurrentInstance();
   ExpressionFactory factory = ExpressionFactory.newInstance();
   return factory.createMethodExpression(
       context.getELContext(), el, null, new Class[] {String.class});
 }
  @Before
  public void setUp() {
    factory = ExpressionFactory.newInstance();
    context = new ELContextImpl();

    TesterBeanA beanA = new TesterBeanA();
    beanA.setName("A");
    context
        .getVariableMapper()
        .setVariable("beanA", factory.createValueExpression(beanA, TesterBeanA.class));

    TesterBeanAA beanAA = new TesterBeanAA();
    beanAA.setName("AA");
    context
        .getVariableMapper()
        .setVariable("beanAA", factory.createValueExpression(beanAA, TesterBeanAA.class));

    TesterBeanAAA beanAAA = new TesterBeanAAA();
    beanAAA.setName("AAA");
    context
        .getVariableMapper()
        .setVariable("beanAAA", factory.createValueExpression(beanAAA, TesterBeanAAA.class));

    beanB = new TesterBeanB();
    beanB.setName("B");
    context
        .getVariableMapper()
        .setVariable("beanB", factory.createValueExpression(beanB, TesterBeanB.class));

    TesterBeanBB beanBB = new TesterBeanBB();
    beanBB.setName("BB");
    context
        .getVariableMapper()
        .setVariable("beanBB", factory.createValueExpression(beanBB, TesterBeanBB.class));

    TesterBeanBBB beanBBB = new TesterBeanBBB();
    beanBBB.setName("BBB");
    context
        .getVariableMapper()
        .setVariable("beanBBB", factory.createValueExpression(beanBBB, TesterBeanBBB.class));

    TesterBeanC beanC = new TesterBeanC();
    context
        .getVariableMapper()
        .setVariable("beanC", factory.createValueExpression(beanC, TesterBeanC.class));

    TesterBeanEnum beanEnum = new TesterBeanEnum();
    context
        .getVariableMapper()
        .setVariable("beanEnum", factory.createValueExpression(beanEnum, TesterBeanEnum.class));
  }
  public static ExpressionFactory newExpressionFactory() {

    // JRF: recommend moving this to an ExpressionFactory implementation of
    // our own that extends the JUEL ExpressionFactoryImpl
    // and register only our ExpressionFactory implementation class name in
    // META-INF/services/javax.el.ExpressionFactory
    // note: this requires changing the JUEL dependency to prevent it from
    // registering their ExpressionFactoryImpl in
    // META-INF/services/javax.el.ExpressionFactory automatically
    Properties props = new Properties();

    props.setProperty("de.odysseus.el.misc.TypeConverter", TypeConverterImpl.class.getName());

    return ExpressionFactory.newInstance(props);
  }
Beispiel #4
0
/** @author LaineyC */
public class Parser {

  public static final ExpressionFactory EXPRESSION_FACTORY = ExpressionFactory.newInstance();

  public static String parseString(String expression, ELContext context) {
    return (String)
        EXPRESSION_FACTORY
            .createValueExpression(context, expression, String.class)
            .getValue(context);
  }

  public static boolean parseBoolean(String expression, ELContext context) {
    return (boolean)
        EXPRESSION_FACTORY
            .createValueExpression(context, expression, boolean.class)
            .getValue(context);
  }

  public static Object parseObject(String expression, ELContext context) {
    return EXPRESSION_FACTORY
        .createValueExpression(context, expression, Object.class)
        .getValue(context);
  }
}
Beispiel #5
0
/**
 * A repository for various info about the translation unit under compilation.
 *
 * @author Kin-man Chung
 */
class PageInfo {

  private final Vector<String> imports;
  private final Map<String, Long> dependants;

  private final BeanRepository beanRepository;
  private final Set<String> varInfoNames;
  private final HashMap<String, TagLibraryInfo> taglibsMap;
  private final HashMap<String, String> jspPrefixMapper;
  private final HashMap<String, LinkedList<String>> xmlPrefixMapper;
  private final HashMap<String, Mark> nonCustomTagPrefixMap;
  private final String jspFile;
  private final String defaultLanguage = "java";
  private String language;
  private final String defaultExtends = Constants.JSP_SERVLET_BASE;
  private String xtends;
  private String contentType = null;
  private String session;
  private boolean isSession = true;
  private String bufferValue;
  private int buffer = 8 * 1024; // XXX confirm
  private String autoFlush;
  private boolean isAutoFlush = true;
  private String isThreadSafeValue;
  private boolean isThreadSafe = true;
  private String isErrorPageValue;
  private boolean isErrorPage = false;
  private String errorPage = null;
  private String info;

  private boolean scriptless = false;
  private boolean scriptingInvalid = false;

  private String isELIgnoredValue;
  private boolean isELIgnored = false;

  // JSP 2.1
  private String deferredSyntaxAllowedAsLiteralValue;
  private boolean deferredSyntaxAllowedAsLiteral = false;
  private final ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
  private String trimDirectiveWhitespacesValue;
  private boolean trimDirectiveWhitespaces = false;

  private String omitXmlDecl = null;
  private String doctypeName = null;
  private String doctypePublic = null;
  private String doctypeSystem = null;

  private boolean isJspPrefixHijacked;

  // Set of all element and attribute prefixes used in this translation unit
  private final HashSet<String> prefixes;

  private boolean hasJspRoot = false;
  private Collection<String> includePrelude;
  private Collection<String> includeCoda;
  private final Vector<String> pluginDcls; // Id's for tagplugin declarations

  // JSP 2.2
  private boolean errorOnUndeclaredNamepsace = false;

  private final boolean isTagFile;

  PageInfo(BeanRepository beanRepository, String jspFile, boolean isTagFile) {
    this.isTagFile = isTagFile;
    this.jspFile = jspFile;
    this.beanRepository = beanRepository;
    this.varInfoNames = new HashSet<>();
    this.taglibsMap = new HashMap<>();
    this.jspPrefixMapper = new HashMap<>();
    this.xmlPrefixMapper = new HashMap<>();
    this.nonCustomTagPrefixMap = new HashMap<>();
    this.imports = new Vector<>();
    this.dependants = new HashMap<>();
    this.includePrelude = new Vector<>();
    this.includeCoda = new Vector<>();
    this.pluginDcls = new Vector<>();
    this.prefixes = new HashSet<>();

    // Enter standard imports
    imports.addAll(Constants.STANDARD_IMPORTS);
  }

  public boolean isTagFile() {
    return isTagFile;
  }

  /**
   * Check if the plugin ID has been previously declared. Make a not that this Id is now declared.
   *
   * @return true if Id has been declared.
   */
  public boolean isPluginDeclared(String id) {
    if (pluginDcls.contains(id)) return true;
    pluginDcls.add(id);
    return false;
  }

  public void addImports(List<String> imports) {
    this.imports.addAll(imports);
  }

  public void addImport(String imp) {
    this.imports.add(imp);
  }

  public List<String> getImports() {
    return imports;
  }

  public String getJspFile() {
    return jspFile;
  }

  public void addDependant(String d, Long lastModified) {
    if (!dependants.containsKey(d) && !jspFile.equals(d)) dependants.put(d, lastModified);
  }

  public Map<String, Long> getDependants() {
    return dependants;
  }

  public BeanRepository getBeanRepository() {
    return beanRepository;
  }

  public void setScriptless(boolean s) {
    scriptless = s;
  }

  public boolean isScriptless() {
    return scriptless;
  }

  public void setScriptingInvalid(boolean s) {
    scriptingInvalid = s;
  }

  public boolean isScriptingInvalid() {
    return scriptingInvalid;
  }

  public Collection<String> getIncludePrelude() {
    return includePrelude;
  }

  public void setIncludePrelude(Collection<String> prelude) {
    includePrelude = prelude;
  }

  public Collection<String> getIncludeCoda() {
    return includeCoda;
  }

  public void setIncludeCoda(Collection<String> coda) {
    includeCoda = coda;
  }

  public void setHasJspRoot(boolean s) {
    hasJspRoot = s;
  }

  public boolean hasJspRoot() {
    return hasJspRoot;
  }

  public String getOmitXmlDecl() {
    return omitXmlDecl;
  }

  public void setOmitXmlDecl(String omit) {
    omitXmlDecl = omit;
  }

  public String getDoctypeName() {
    return doctypeName;
  }

  public void setDoctypeName(String doctypeName) {
    this.doctypeName = doctypeName;
  }

  public String getDoctypeSystem() {
    return doctypeSystem;
  }

  public void setDoctypeSystem(String doctypeSystem) {
    this.doctypeSystem = doctypeSystem;
  }

  public String getDoctypePublic() {
    return doctypePublic;
  }

  public void setDoctypePublic(String doctypePublic) {
    this.doctypePublic = doctypePublic;
  }

  /* Tag library and XML namespace management methods */

  public void setIsJspPrefixHijacked(boolean isHijacked) {
    isJspPrefixHijacked = isHijacked;
  }

  public boolean isJspPrefixHijacked() {
    return isJspPrefixHijacked;
  }

  /*
   * Adds the given prefix to the set of prefixes of this translation unit.
   *
   * @param prefix The prefix to add
   */
  public void addPrefix(String prefix) {
    prefixes.add(prefix);
  }

  /*
   * Checks to see if this translation unit contains the given prefix.
   *
   * @param prefix The prefix to check
   *
   * @return true if this translation unit contains the given prefix, false
   * otherwise
   */
  public boolean containsPrefix(String prefix) {
    return prefixes.contains(prefix);
  }

  /*
   * Maps the given URI to the given tag library.
   *
   * @param uri The URI to map
   * @param info The tag library to be associated with the given URI
   */
  public void addTaglib(String uri, TagLibraryInfo info) {
    taglibsMap.put(uri, info);
  }

  /*
   * Gets the tag library corresponding to the given URI.
   *
   * @return Tag library corresponding to the given URI
   */
  public TagLibraryInfo getTaglib(String uri) {
    return taglibsMap.get(uri);
  }

  /*
   * Gets the collection of tag libraries that are associated with a URI
   *
   * @return Collection of tag libraries that are associated with a URI
   */
  public Collection<TagLibraryInfo> getTaglibs() {
    return taglibsMap.values();
  }

  /*
   * Checks to see if the given URI is mapped to a tag library.
   *
   * @param uri The URI to map
   *
   * @return true if the given URI is mapped to a tag library, false
   * otherwise
   */
  public boolean hasTaglib(String uri) {
    return taglibsMap.containsKey(uri);
  }

  /*
   * Maps the given prefix to the given URI.
   *
   * @param prefix The prefix to map
   * @param uri The URI to be associated with the given prefix
   */
  public void addPrefixMapping(String prefix, String uri) {
    jspPrefixMapper.put(prefix, uri);
  }

  /*
   * Pushes the given URI onto the stack of URIs to which the given prefix
   * is mapped.
   *
   * @param prefix The prefix whose stack of URIs is to be pushed
   * @param uri The URI to be pushed onto the stack
   */
  public void pushPrefixMapping(String prefix, String uri) {
    LinkedList<String> stack = xmlPrefixMapper.get(prefix);
    if (stack == null) {
      stack = new LinkedList<>();
      xmlPrefixMapper.put(prefix, stack);
    }
    stack.addFirst(uri);
  }

  /*
   * Removes the URI at the top of the stack of URIs to which the given
   * prefix is mapped.
   *
   * @param prefix The prefix whose stack of URIs is to be popped
   */
  public void popPrefixMapping(String prefix) {
    LinkedList<String> stack = xmlPrefixMapper.get(prefix);
    stack.removeFirst();
  }

  /*
   * Returns the URI to which the given prefix maps.
   *
   * @param prefix The prefix whose URI is sought
   *
   * @return The URI to which the given prefix maps
   */
  public String getURI(String prefix) {

    String uri = null;

    LinkedList<String> stack = xmlPrefixMapper.get(prefix);
    if (stack == null || stack.size() == 0) {
      uri = jspPrefixMapper.get(prefix);
    } else {
      uri = stack.getFirst();
    }

    return uri;
  }

  /* Page/Tag directive attributes */

  /*
   * language
   */
  public void setLanguage(String value, Node n, ErrorDispatcher err, boolean pagedir)
      throws JasperException {

    if (!"java".equalsIgnoreCase(value)) {
      if (pagedir) err.jspError(n, "jsp.error.page.language.nonjava");
      else err.jspError(n, "jsp.error.tag.language.nonjava");
    }

    language = value;
  }

  public String getLanguage(boolean useDefault) {
    return (language == null && useDefault ? defaultLanguage : language);
  }

  /*
   * extends
   */
  public void setExtends(String value) {
    xtends = value;
  }

  /**
   * Gets the value of the 'extends' page directive attribute.
   *
   * @param useDefault TRUE if the default (org.apache.jasper.runtime.HttpJspBase) should be
   *     returned if this attribute has not been set, FALSE otherwise
   * @return The value of the 'extends' page directive attribute, or the default
   *     (org.apache.jasper.runtime.HttpJspBase) if this attribute has not been set and useDefault
   *     is TRUE
   */
  public String getExtends(boolean useDefault) {
    return (xtends == null && useDefault ? defaultExtends : xtends);
  }

  /**
   * Gets the value of the 'extends' page directive attribute.
   *
   * @return The value of the 'extends' page directive attribute, or the default
   *     (org.apache.jasper.runtime.HttpJspBase) if this attribute has not been set
   */
  public String getExtends() {
    return getExtends(true);
  }

  /*
   * contentType
   */
  public void setContentType(String value) {
    contentType = value;
  }

  public String getContentType() {
    return contentType;
  }

  /*
   * buffer
   */
  public void setBufferValue(String value, Node n, ErrorDispatcher err) throws JasperException {

    if ("none".equalsIgnoreCase(value)) buffer = 0;
    else {
      if (value == null || !value.endsWith("kb")) {
        if (n == null) {
          err.jspError("jsp.error.page.invalid.buffer");
        } else {
          err.jspError(n, "jsp.error.page.invalid.buffer");
        }
      }
      try {
        @SuppressWarnings("null") // value can't be null here
        int k = Integer.parseInt(value.substring(0, value.length() - 2));
        buffer = k * 1024;
      } catch (NumberFormatException e) {
        if (n == null) {
          err.jspError("jsp.error.page.invalid.buffer");
        } else {
          err.jspError(n, "jsp.error.page.invalid.buffer");
        }
      }
    }

    bufferValue = value;
  }

  public String getBufferValue() {
    return bufferValue;
  }

  public int getBuffer() {
    return buffer;
  }

  /*
   * session
   */
  public void setSession(String value, Node n, ErrorDispatcher err) throws JasperException {

    if ("true".equalsIgnoreCase(value)) isSession = true;
    else if ("false".equalsIgnoreCase(value)) isSession = false;
    else err.jspError(n, "jsp.error.page.invalid.session");

    session = value;
  }

  public String getSession() {
    return session;
  }

  public boolean isSession() {
    return isSession;
  }

  /*
   * autoFlush
   */
  public void setAutoFlush(String value, Node n, ErrorDispatcher err) throws JasperException {

    if ("true".equalsIgnoreCase(value)) isAutoFlush = true;
    else if ("false".equalsIgnoreCase(value)) isAutoFlush = false;
    else err.jspError(n, "jsp.error.autoFlush.invalid");

    autoFlush = value;
  }

  public String getAutoFlush() {
    return autoFlush;
  }

  public boolean isAutoFlush() {
    return isAutoFlush;
  }

  /*
   * isThreadSafe
   */
  public void setIsThreadSafe(String value, Node n, ErrorDispatcher err) throws JasperException {

    if ("true".equalsIgnoreCase(value)) isThreadSafe = true;
    else if ("false".equalsIgnoreCase(value)) isThreadSafe = false;
    else err.jspError(n, "jsp.error.page.invalid.isthreadsafe");

    isThreadSafeValue = value;
  }

  public String getIsThreadSafe() {
    return isThreadSafeValue;
  }

  public boolean isThreadSafe() {
    return isThreadSafe;
  }

  /*
   * info
   */
  public void setInfo(String value) {
    info = value;
  }

  public String getInfo() {
    return info;
  }

  /*
   * errorPage
   */
  public void setErrorPage(String value) {
    errorPage = value;
  }

  public String getErrorPage() {
    return errorPage;
  }

  /*
   * isErrorPage
   */
  public void setIsErrorPage(String value, Node n, ErrorDispatcher err) throws JasperException {

    if ("true".equalsIgnoreCase(value)) isErrorPage = true;
    else if ("false".equalsIgnoreCase(value)) isErrorPage = false;
    else err.jspError(n, "jsp.error.page.invalid.iserrorpage");

    isErrorPageValue = value;
  }

  public String getIsErrorPage() {
    return isErrorPageValue;
  }

  public boolean isErrorPage() {
    return isErrorPage;
  }

  /*
   * isELIgnored
   */
  public void setIsELIgnored(String value, Node n, ErrorDispatcher err, boolean pagedir)
      throws JasperException {

    if ("true".equalsIgnoreCase(value)) isELIgnored = true;
    else if ("false".equalsIgnoreCase(value)) isELIgnored = false;
    else {
      if (pagedir) err.jspError(n, "jsp.error.page.invalid.iselignored");
      else err.jspError(n, "jsp.error.tag.invalid.iselignored");
    }

    isELIgnoredValue = value;
  }

  /*
   * deferredSyntaxAllowedAsLiteral
   */
  public void setDeferredSyntaxAllowedAsLiteral(
      String value, Node n, ErrorDispatcher err, boolean pagedir) throws JasperException {

    if ("true".equalsIgnoreCase(value)) deferredSyntaxAllowedAsLiteral = true;
    else if ("false".equalsIgnoreCase(value)) deferredSyntaxAllowedAsLiteral = false;
    else {
      if (pagedir) err.jspError(n, "jsp.error.page.invalid.deferredsyntaxallowedasliteral");
      else err.jspError(n, "jsp.error.tag.invalid.deferredsyntaxallowedasliteral");
    }

    deferredSyntaxAllowedAsLiteralValue = value;
  }

  /*
   * trimDirectiveWhitespaces
   */
  public void setTrimDirectiveWhitespaces(
      String value, Node n, ErrorDispatcher err, boolean pagedir) throws JasperException {

    if ("true".equalsIgnoreCase(value)) trimDirectiveWhitespaces = true;
    else if ("false".equalsIgnoreCase(value)) trimDirectiveWhitespaces = false;
    else {
      if (pagedir) err.jspError(n, "jsp.error.page.invalid.trimdirectivewhitespaces");
      else err.jspError(n, "jsp.error.tag.invalid.trimdirectivewhitespaces");
    }

    trimDirectiveWhitespacesValue = value;
  }

  public void setELIgnored(boolean s) {
    isELIgnored = s;
  }

  public String getIsELIgnored() {
    return isELIgnoredValue;
  }

  public boolean isELIgnored() {
    return isELIgnored;
  }

  public void putNonCustomTagPrefix(String prefix, Mark where) {
    nonCustomTagPrefixMap.put(prefix, where);
  }

  public Mark getNonCustomTagPrefix(String prefix) {
    return nonCustomTagPrefixMap.get(prefix);
  }

  public String getDeferredSyntaxAllowedAsLiteral() {
    return deferredSyntaxAllowedAsLiteralValue;
  }

  public boolean isDeferredSyntaxAllowedAsLiteral() {
    return deferredSyntaxAllowedAsLiteral;
  }

  public void setDeferredSyntaxAllowedAsLiteral(boolean isELDeferred) {
    this.deferredSyntaxAllowedAsLiteral = isELDeferred;
  }

  public ExpressionFactory getExpressionFactory() {
    return expressionFactory;
  }

  public String getTrimDirectiveWhitespaces() {
    return trimDirectiveWhitespacesValue;
  }

  public boolean isTrimDirectiveWhitespaces() {
    return trimDirectiveWhitespaces;
  }

  public void setTrimDirectiveWhitespaces(boolean trimDirectiveWhitespaces) {
    this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
  }

  public Set<String> getVarInfoNames() {
    return varInfoNames;
  }

  public boolean isErrorOnUndeclaredNamespace() {
    return errorOnUndeclaredNamepsace;
  }

  public void setErrorOnUndeclaredNamespace(boolean errorOnUndeclaredNamespace) {
    this.errorOnUndeclaredNamepsace = errorOnUndeclaredNamespace;
  }
}
 private <T> ValueExpression createElExpression(
     ELContext elContext, String exp, Class<T> valueType) {
   ExpressionFactory factory = ExpressionFactory.newInstance();
   ValueExpression valueExpression = factory.createValueExpression(elContext, exp, valueType);
   return valueExpression;
 }
  @Before
  public void setUp() throws Exception {
    context =
        new Mockery() {
          {
            setThrowFirstErrorOnAssertIsSatisfied(true);
          }
        };
    context.setThreadingPolicy(new Synchroniser());

    upstream = context.mock(ChannelUpstreamHandler.class);
    downstream = context.mock(ChannelDownstreamHandler.class);

    execution = new ExecutionHandler();

    List<MessageEncoder> encoders = new ArrayList<MessageEncoder>();
    encoders.add(new WriteBytesEncoder(new byte[] {0x01, 0x02, 0x03}));
    encoders.add(new WriteTextEncoder("Hello, world", UTF_8));

    ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
    environment = new ExpressionContext();
    expression = expressionFactory.createValueExpression(environment, "${variable}", byte[].class);
    encoders.add(new WriteExpressionEncoder(expression, environment));

    masker = newMasker(maskingKey);
    handler = new WriteHandler(encoders, newMasker(maskingKey));

    pipeline =
        pipeline(
            new SimpleChannelHandler() {
              @Override
              public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent evt)
                  throws Exception {
                downstream.handleDownstream(ctx, evt);
                super.handleDownstream(ctx, evt);
              }

              @Override
              public void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
                  throws Exception {
                Object message = e.getMessage();
                e.getFuture().setSuccess();
                if (message instanceof ChannelBuffer) {
                  ChannelBuffer buf = (ChannelBuffer) message;
                  fireWriteComplete(ctx, buf.readableBytes());
                }
              }
            },
            execution,
            handler,
            new SimpleChannelHandler() {
              @Override
              public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
                  throws Exception {
                upstream.handleUpstream(ctx, e);
                super.handleUpstream(ctx, e);
              }

              @Override
              public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
                  throws Exception {
                // prevent console error message
              }
            });

    channelFactory = new DefaultLocalClientChannelFactory();
  }
Beispiel #8
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);
  }