示例#1
0
  /** @see javax.servlet.jsp.tagext.Tag#doEndTag() */
  public int doEndTag() throws JspException {
    getLogger().debug("TableTag: inizio doEndTag()");

    if (isParameterPresent()) {
      String link;
      if ((action != null) && !action.equals("")) {
        // String a=((HttpServletRequest) pageContext.getRequest()).getServletPath();
        // String b=((HttpServletRequest) pageContext.getRequest()).getRequestURI();
        String contextPath = ((HttpServletRequest) pageContext.getRequest()).getContextPath();
        link = contextPath + action;
      } else {
        link = ((HttpServletRequest) pageContext.getRequest()).getRequestURI();
      }

      String root = ((HttpServletRequest) pageContext.getRequest()).getContextPath();

      boolean showLinkB = showLink == null || !showLink.equals("false");

      // se la query è in esecuzione settiamo il flag isLoading anche su TableModel
      if (paginator.isLoading()) tableModel.setLoading(true);
      else tableModel.setLoading(false);

      String contextPath = ((HttpServletRequest) pageContext.getRequest()).getContextPath();

      HtmlTableFactory htmlTableFactory;
      if ((action != null) && (!action.equals(""))) {
        htmlTableFactory =
            new HtmlTableFactory(
                tableModel,
                styleClass,
                pageToShow,
                paginator.getMaxPageNumber(),
                link,
                root,
                showLinkB,
                textToShow,
                intestazione,
                paginator.getElementsFoundNumber(),
                pageToShowParamName,
                useSmartLoading,
                timeToRefresh,
                contextPath,
                refreshUrl,
                true,
                actionExportExcel,
                this.paginator.getMaxRowPage(),
                methodChangeNumElements);
      } else {
        htmlTableFactory =
            new HtmlTableFactory(
                tableModel,
                styleClass,
                pageToShow,
                paginator.getMaxPageNumber(),
                link,
                root,
                showLinkB,
                textToShow,
                intestazione,
                paginator.getElementsFoundNumber(),
                pageToShowParamName,
                useSmartLoading,
                timeToRefresh,
                contextPath,
                refreshUrl,
                this.paginator.getMaxRowPage(),
                methodChangeNumElements);
      }

      String HTMLCode = htmlTableFactory.getHTMLCode();

      // avg PROVA
      //			       if (!tableModel.isLoading()){
      //					ExcelTableFactory excelFactory=new ExcelTableFactory(tableModel);
      //					excelFactory.createExcel(pageContext);
      //			       }
      // fine PROVA

      // se i dati sono ancora in caricamento
      // mette in page context la pagina di refresh e il tempo di refresh
      if (useSmartLoading && this.tableModel.isLoading()) {
        System.out.println("setto refresh per pager:" + paginator.getAttributeKey());
        pageContext.setAttribute("refreshUrl", contextPath + refreshUrl, PageContext.REQUEST_SCOPE);
        pageContext.setAttribute("timeToRefresh", timeToRefresh, PageContext.REQUEST_SCOPE);

        // incrementa il numero dei queryExecutor in esecuzione
        // adesso lo fa il Paginator
      } else {

        // decrementa il numero dei queryExecutor in esecuzione
        // ora lo fa il Paginator

      }

      try {
        pageContext.getOut().print(HTMLCode);
      } catch (IOException e) {
        getLogger().error("TableTag::doEndTag()::IOException::" + e.getMessage());
        throw new JspTagException("errore scrittura codice HTML");
      }
    }
    getLogger().debug("TableTag: fine doEndTag()");

    return super.doEndTag();
  }