Beispiel #1
0
  public int doEndTag() throws JspException {
    try {
      HttpServletRequest request = (HttpServletRequest) (pageContext.getRequest());
      String file_ext = pageContext.getServletContext().getInitParameter("FileExtention");
      String dbfs_ext = pageContext.getServletContext().getInitParameter("DatabaseExtention");
      String db_name = pageContext.getServletContext().getInitParameter("DatabaseName");
      String db_query = pageContext.getServletContext().getInitParameter("DatabaseQuery");
      JspWriter out = pageContext.getOut();

      int KEEP_CACHE_TIME = 300;
      long current_time = System.currentTimeMillis();

      if (pagebody != null || pageurl != null || dbfsurl != null) {
        VariableTable vt = new VariableTable();
        vt.loadContent(FileCache.getFileContent(getPhysicalPath("/global" + file_ext)));
        vt.loadContent(FileCache.getFileContent(getPhysicalPath("default" + file_ext)));
        if (pageurl != null) vt.loadContent(FileCache.getFileContent(getPhysicalPath(pageurl)));
        if (dbfsurl != null) {
          VariableTable dbparam = new VariableTable();
          dbparam.add("path", java.sql.Types.VARCHAR);
          dbparam.setValue("path", dbfsurl);
          String pagebody = TextCache.getTextContent("source::" + dbfsurl);
          if (pagebody == null) {
            try {
              DBPooledConnection dbconn = DBLogicalManager.getPoolConnection(db_name);
              try {
                pagebody = DBOperation.getString(dbconn, db_query, dbparam);
                vt.loadContent(pagebody);
                TextCache.putContent(
                    System.currentTimeMillis(), "source::" + dbfsurl, pagebody, 20);
              } catch (java.sql.SQLException sqle) {
              }
              dbconn.close();
            } catch (java.lang.Exception sqle) {
            }
          } else {
            vt.loadContent(pagebody);
          }
        }
        if (pagebody != null) vt.loadContent(pagebody);
        getEnv(vt);
        vt.add("JSP.TAG", java.sql.Types.VARCHAR);
        vt.setValue("JSP.TAG", "YES");
        vt.add("REQUEST.URL", java.sql.Types.VARCHAR);
        vt.setValue("REQUEST.URL", request.getRequestURI());

        if (vt.exists("WEBCHART.KEEP_CACHE_TIME")) {
          KEEP_CACHE_TIME = vt.getInt("WEBCHART.KEEP_CACHE_TIME", 300);
          if (KEEP_CACHE_TIME < 5) KEEP_CACHE_TIME = 5;
        }
        java.io.File xsl_file = null;
        if (vt.getString("WEBCHART.XSLDOC") != null)
          xsl_file = new java.io.File(getPhysicalPath(vt.getString("WEBCHART.XSLDOC")));
        String cachekey = vt.parseString(vt.getString("WEBCHART.CACHE"));

        String cache_content = null;

        if (cachekey != null && !vt.exists("WEBCHART.FORCECACHE"))
          cache_content = TextCache.getTextContent(cachekey);

        if (cache_content == null) {
          java.io.StringWriter xmlbuf = new java.io.StringWriter();
          writeXMLHeader(xmlbuf, vt);
          xmlbuf.write("<root>\n");
          WebChart2.generateChart(xmlbuf, null, vt, file_ext);
          xmlbuf.write("</root>\n");

          java.io.StringWriter htmlbuf = new java.io.StringWriter();
          if (xsl_file != null && xsl_file.exists())
            BaseServlet.XML2HTML(
                htmlbuf,
                new java.io.StringReader(xmlbuf.toString()),
                new java.io.StringReader(FileCache.getFileContent(xsl_file)),
                FileCache.getFileContent(xsl_file));
          else
            BaseServlet.XML2HTML(
                htmlbuf,
                new java.io.StringReader(xmlbuf.toString()),
                new java.io.StringReader(StaticResource.getTextResource("defaultxsl")),
                StaticResource.getTextResource("defaultxsl"));
          cache_content = htmlbuf.toString();
          out.write(cache_content);
          if (cachekey != null)
            TextCache.putContent(current_time, cachekey, cache_content, KEEP_CACHE_TIME);
        } else {
          out.write(cache_content);
        }
      }
    } catch (IOException ioe) {
      throw new JspException("Error:    " + ioe.getMessage());
    }
    return EVAL_PAGE;
  }
  private String getXmlFromBean() {
    String xml = null;
    HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
    i_action formAction = null;
    i_bean formBean = null;
    if (bean != null) {
      HashMap pool = (HashMap) request.getAttribute(bsController.CONST_BEAN_$INSTANCEACTIONPOOL);
      if (pool != null) formAction = (i_action) pool.get(bean);
    }
    if (formAction != null) bean = null;
    else formAction = (i_action) request.getAttribute(bsController.CONST_BEAN_$INSTANCEACTION);
    if (formAction == null) formAction = new action();
    if (bean == null) formBean = formAction.get_bean();

    if (method_prefix == null) method_prefix = "get";
    Object writeValue = null;
    Object anotherBean = null;

    if (bean == null) {
      anotherBean = formBean;
      if (anotherBean != null) {
        if (name == null) writeValue = anotherBean;
        else writeValue = util_reflect.prepareWriteValueForTag(formBean, method_prefix, name, null);
      }

    } else {

      if (bean.equals(bsConstants.CONST_TAG_REQUESTPARAMETER))
        anotherBean = request.getParameter(name);
      if (bean.equals(bsConstants.CONST_TAG_SYSTEMPROPERTY)) anotherBean = System.getProperty(name);
      if (anotherBean == null) anotherBean = request.getAttribute(bean);
      if (anotherBean == null) anotherBean = request.getSession().getAttribute(bean);
      if (anotherBean == null) anotherBean = util_tag.getBeanAsBSTag(bean, this);
      try {
        if (anotherBean == null)
          anotherBean =
              ((info_navigation)
                      request.getSession().getAttribute(bsConstants.CONST_BEAN_$NAVIGATION))
                  .find(bean)
                  .get_content();
      } catch (Exception e) {
      }

      if (anotherBean != null) {
        if (name == null) writeValue = anotherBean;
        else {
          try {
            writeValue =
                util_reflect.prepareWriteValueForTag(anotherBean, method_prefix, name, null);
          } catch (Exception e) {
          }
        }
      }
    }

    if (writeValue != null) {
      try {
        xml = util_beanMessageFactory.bean2message(writeValue);
      } catch (Exception e) {

      }
    }

    return xml;
  }