/**
   * Did the client provide the minimal parameters required?
   *
   * @return true If so
   */
  private boolean verifyMinimumParameters() {
    int count = 0;

    if (!StringUtil.isNullString(getParameter(AP_E_PUBLICATION))) count++;
    if (!StringUtil.isNullString(getParameter(AP_E_CLASSNAME))) count++;
    if (!StringUtil.isNullString(getParameter(AP_E_PLUGIN))) count++;

    return (count > 0);
  }
  /**
   * A target system is required to create an AU - was it provided?
   *
   * @return true If at least one target was specified
   */
  private boolean verifyTarget() {
    if (!isCreateCommand()) {
      return true;
    }

    return !StringUtil.isNullString(getParameter(AP_E_TARGET));
  }
  /**
   * Are all of the "defining parameters" required to create an AU available?
   *
   * @return true If so
   */
  private boolean verifyDefiningParameters() {
    KeyedList parameters;
    int size;

    if (!isCreateCommand()) {
      return true;
    }

    parameters = ParseUtils.getDynamicFields(getXmlUtils(), getRequestDocument(), AP_MD_AUDEFINING);
    size = parameters.size();

    for (int i = 0; i < size; i++) {
      if (StringUtil.isNullString((String) parameters.getValue(i))) {
        return false;
      }
    }
    return true;
  }
示例#4
0
  // 一周内的污染源在线脱机联机报表
  public static void run7(HttpServletRequest req) throws Exception {

    String gas_station_type = "2";
    String water_station_type = "1";
    String so2_col = "val01";
    String cod_col = "val02";

    Connection cn = null;
    String sql = null;
    List list = new ArrayList(); // 存储这周内的数据
    List list2 = new ArrayList(); // 存储今天的数据
    List list3 = new ArrayList(); // 存储脱机的数据
    List l_temp = null;
    List td_temp = null; // 存储今天的数据
    String kv = null;
    String kv_2 = null;
    Map tmp = null;
    Map tmp_2 = null;

    Map tmp2 = new HashMap();
    Map tmp3 = new HashMap();
    Map data = null; // 存这周内有数据的站位
    Map data2 = null; // 存储今天的数据
    Map data3 = null; // 存储这周脱机的站位
    List waterStationList = null;
    List gasStationList = null;
    // String date = req.getParameter("date");
    String now = StringUtil.getNowDate() + "";
    // String now = req.getParameter("date")+"";//黄宝修改
    String date1, date2 = null;
    // 从现在开始,退后7天。
    Calendar cal = Calendar.getInstance();
    Calendar cal2 = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    cal.setTime(cal.getTime());

    cal.add(Calendar.DAY_OF_MONTH, -7); // 退后7天

    String now_7 = sdf.format(cal.getTime());

    cal2.setTime(cal2.getTime());

    cal2.add(Calendar.DAY_OF_MONTH, -1); // 退后1天

    String now_1 = sdf.format(cal2.getTime()) + " 23:59:59";
    ;
    date1 = sdf.format(cal2.getTime()) + " 23:59:59";
    date2 = now_7 + "";

    Map areaMap = null;
    Map bean = new HashMap();

    int i, num = 0;
    Map m = null;
    String area_id = null;
    try {

      area_id = req.getParameter("area_id");
      if (area_id == null) {
        area_id = "";
      }

      // date1 = req.getParameter("date1");
      // date1 = req.getParameter("date1");

      sql =
          "select station_id,m_time,"
              + so2_col
              + ","
              + cod_col
              + " from "
              + req.getParameter("tableName");
      sql = sql + " where m_time>='" + date2 + "' and m_time<='" + date1 + "'";
      sql = sql + " and station_id in (";
      sql =
          sql
              + "select station_id from t_cfg_station_info where station_type in ('1','2') and area_id like '"
              + area_id
              + "%') order by m_time desc";

      // System.out.println(sql);

      cn = f.getConn();

      // System.out.println(sql);

      l_temp = f.query(cn, sql, null); // 最近一周的数据
      num = l_temp.size();
      for (i = 0; i < num; i++) {
        tmp = (Map) l_temp.get(i);
        kv = (String) tmp.get("station_id");

        String station_id_t = (String) tmp2.get(kv);
        if ("".equals(station_id_t) || station_id_t == null) {
          list.add(tmp); // 最近一周都有的数据
          tmp2.put(kv, kv);
        }
      }

      // data = f.getListMap(list,"station_id");//最近一周都有的数据

      // 查询今天有数据的站位
      String now_time = StringUtil.getNowDate() + "";
      date1 = now_time + "";
      date2 = now_time + " 23:59:59";

      sql =
          "select station_id,m_time,"
              + so2_col
              + ","
              + cod_col
              + " from "
              + req.getParameter("tableName");
      sql = sql + " where m_time>='" + date1 + "' and m_time<='" + date2 + "'";
      sql = sql + " and station_id in (";
      sql =
          sql
              + "select station_id from t_cfg_station_info where station_type in ('1','2') and area_id like '"
              + area_id
              + "%') order by m_time desc";

      td_temp = f.query(cn, sql, null); // 今天的数据
      tmp2 = null;

      num = td_temp.size();
      for (i = 0; i < num; i++) {
        tmp = (Map) td_temp.get(i);
        kv = (String) tmp.get("station_id");

        String station_id_t = (String) tmp3.get(kv);
        if ("".equals(station_id_t) || station_id_t == null) {
          list2.add(tmp); // 今天有数据的站位。
          tmp3.put(kv, kv);
        }
      }

      // 循环这一周内有数据的站位列表list,如果list中的站位不能在今天的站位信息列表中list2中找到的话,则表明是脱机
      num = list.size();
      int j = 0;
      int num2 = list2.size();
      String station_id_1 = "";
      String station_id_2 = "";
      int l = 0;
      for (i = 0; i < num; i++) {
        tmp = (Map) list.get(i);
        station_id_1 = (String) tmp.get("station_id");
        l = 0;
        for (j = 0; j < num2; j++) {
          tmp_2 = (Map) list2.get(j);
          station_id_2 = (String) tmp_2.get("station_id");
          if (station_id_1.equals(station_id_2)) {
            l++;
          }
        }
        if (l == 0) {
          list3.add(tmp);
        }
      }

      data = f.getListMap(list3, "station_id"); // 这周脱机的站位信息列表

      l_temp = null;
      tmp = null;
      list2 = null;
      list3 = null;
      tmp_2 = null;
      tmp3 = null;

      sql =
          "select station_id,station_desc,ep_type,area_id,station_bz from t_cfg_station_info where station_type='1' and area_id like '"
              + area_id
              + "%' order by area_id,station_desc";
      waterStationList = f.query(cn, sql, null);

      // System.out.println(sql);

      sql =
          "select station_id,station_desc,ep_type,area_id from t_cfg_station_info where station_type='2' and area_id like '"
              + area_id
              + "%' order by area_id,station_desc";
      gasStationList = f.query(cn, sql, null);

      // System.out.println(sql);

      sql = "select area_id,area_name from t_cfg_area";
      areaMap = f.getMap(cn, sql);

      // System.out.println(sql);
      num = waterStationList.size();
      for (i = 0; i < num; i++) {
        m = (Map) waterStationList.get(i);
        area_id = (String) m.get("area_id");
        m.put("area_name", areaMap.get(area_id));
      }

      num = gasStationList.size();
      for (i = 0; i < num; i++) {
        m = (Map) gasStationList.get(i);
        area_id = (String) m.get("area_id");
        m.put("area_name", areaMap.get(area_id));
      }

      // System.out.println("before close,cn="+cn);
      f.close(cn);
      // System.out.println("after close,cn="+cn);

      int waterOnlineNum, gasOnlineNum, onlineNum = 0;
      int waterOfflineNum, gasOfflineNum, offlineNum = 0;
      int waterOfflineNumNation, gasOfflineNumNation, offlineNumNation = 0;
      int waterZeroNum, gasZeroNum, zeroNum = 0;
      int waterZeroNumNation, gasZeroNumNation, zeroNumNation = 0;

      waterOnlineNum = OnlineReport.getOnlineNum(waterStationList, data);
      gasOnlineNum = OnlineReport.getOnlineNum(gasStationList, data);
      onlineNum = waterOnlineNum + gasOnlineNum;

      // System.out.println(onlineNum);

      waterOfflineNum = OnlineReport.getOfflineNum(waterStationList, data);
      gasOfflineNum = OnlineReport.getOfflineNum(gasStationList, data);
      offlineNum = waterOfflineNum + gasOfflineNum;

      // System.out.println("zeroNumNation "+zeroNumNation);

      waterOfflineNumNation = OnlineReport.getOfflineNumNation(waterStationList, data);
      gasOfflineNumNation = OnlineReport.getOfflineNumNation(gasStationList, data);
      offlineNumNation = waterOfflineNumNation + gasOfflineNumNation;

      // System.out.println("offlineNumNation "+offlineNumNation);

      waterZeroNum = OnlineReport.getZeroNum(waterStationList, data, cod_col);
      gasZeroNum = OnlineReport.getZeroNum(gasStationList, data, so2_col);
      zeroNum = waterZeroNum + gasZeroNum;

      // System.out.println(zeroNum);

      waterZeroNumNation = OnlineReport.getZeroNumNation(waterStationList, data, cod_col);
      gasZeroNumNation = OnlineReport.getZeroNumNation(gasStationList, data, so2_col);
      zeroNumNation = waterZeroNumNation + gasZeroNumNation;

      // System.out.println(zeroNumNation);

      bean.put("waterOnlineNum", waterOnlineNum + "");
      bean.put("gasOnlineNum", gasOnlineNum + "");
      bean.put("onlineNum", onlineNum + "");

      bean.put("waterOfflineNum", waterOfflineNum + "");
      bean.put("gasOfflineNum", gasOfflineNum + "");
      bean.put("offlineNum", offlineNum + "");

      bean.put("waterOfflineNumNation", waterOfflineNumNation + "");
      bean.put("gasOfflineNumNation", gasOfflineNumNation + "");
      bean.put("offlineNumNation", offlineNumNation + "");

      bean.put("waterZeroNum", waterZeroNum + "");
      bean.put("gasZeroNum", gasZeroNum + "");
      bean.put("zeroNum", zeroNum + "");

      bean.put("waterZeroNumNation", waterZeroNumNation + "");
      bean.put("gasZeroNumNation", gasZeroNumNation + "");
      bean.put("zeroNumNation", zeroNumNation + "");

      date1 = now_7;
      date2 = StringUtil.getNowDate() + "";

      bean.put("date1", date2);
      bean.put("date2", date1);

      req.setAttribute("bean", bean);

      list = getOfflineList2(waterStationList, data);
      req.setAttribute("waterOfflineList", list);

      list = getOfflineList2(gasStationList, data);
      req.setAttribute("gasOfflineList", list);

      list = getOfflineListNation(waterStationList, data);
      req.setAttribute("waterOfflineListNation", list);

      list = getOfflineListNation(gasStationList, data);
      req.setAttribute("gasOfflineListNation", list);

      list = getZeroListNation(waterStationList, data, cod_col);
      req.setAttribute("waterZeroListNation", list);

      list = getZeroListNation(gasStationList, data, so2_col);
      req.setAttribute("gasZeroListNation", list);

    } catch (Exception e) {
      throw e;
    } finally {
      f.close(cn);
    }
  }
  /** Query the daemon for information required to set up this command */
  private boolean commandSetup() {

    Configuration configuration = null;
    Collection noEditKeys = null;
    String key;
    String value;

    /*
     * Configure a well known publication?
     */
    if ((value = getParameter(AP_E_PUBLICATION)) != null) {
      PluginProxy plugin = getTitlePlugin(value);

      /*
       * Set plugin and Title configuration information
       */
      if (plugin == null) {
        String message = "Unknown Publication:" + value;

        log.warning(message);
        return error(message);
      }

      setPlugin(plugin);
      setTitleConfig(plugin.getTitleConfig(value));

      configuration = getTitleConfig().getConfig();
      noEditKeys = getNoEditKeys();

    } else {
      /*
       * Lookup by Plugin or Class name - set the plugin
       *
       * NB: As of 23-Feb-04, this is not supported from AddAuPage.java.  See
       *     AddAuWithCompleteFunctionalityPage.java for full support.
       */
      if ((value = getParameter(AP_E_PLUGIN)) != null) {
        key = RemoteApi.pluginKeyFromId(value);

      } else if ((value = getParameter(AP_E_CLASSNAME)) != null) {
        key = RemoteApi.pluginKeyFromId(value);

      } else {
        return error("Supply a Publication, Plugin, or Class name");
      }

      if (StringUtil.isNullString(key)) {
        return error("Supply a valid Publication, Plugin, or Class name");
      }

      if (!pluginLoaded(key)) {
        return error("Plugin is not loaded: " + key);
      }

      setPlugin(getPluginProxy(key));
    }

    /*
     * Finally, return an XML rendition of the Plugin and AU key set up
     */
    generateSetupXml(configuration, noEditKeys);
    return true;
  }
示例#6
0
  public static void main(String arg[]) {
    Hashtable ignoreList = new Hashtable();
    Class cl = null;
    Model model = null;
    System.out.println("Synchronizing forms with database...");
    Db.init();

    try {
      DatabaseMetaData meta = Db.getCon().getMetaData();
      String[] types = {"TABLE"};
      ResultSet rs = meta.getTables(null, null, "%", types);

      // read ignore.list
      ignoreList = AutogenerateUtil.readIgnoreList();
      // prepare directory
      File fDir = new File("../../web/WEB-INF/views/crud_form");
      if (!fDir.exists()) fDir.mkdir();
      while (rs.next()) {
        // proper file name generationm
        String className = "";
        String tableName = rs.getString("TABLE_NAME");
        className = StringUtil.toProperClassName(tableName); // space allowed...
        // tableName = tableName.toUpperCase(); //If Oracle that need uppercase tablename. In MySQL
        // in Mac OS X (and probably Linux), it mustbe case sensitive
        // open table
        String sql = "select * from " + tableName;
        PreparedStatement pstmt =
            Db.getCon()
                .prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = pstmt.executeQuery();
        ResultSetMetaData metaColumn = resultSet.getMetaData();
        int nColoumn = metaColumn.getColumnCount();

        // get foreign keys,and stored it in hashtable
        ResultSet rsFk = meta.getImportedKeys(Db.getCon().getCatalog(), null, tableName);
        Hashtable hashFk = new Hashtable();
        System.out.println("FK Infos for table " + tableName);
        while (rsFk.next()) {
          String pkTableName = rsFk.getString("PKTABLE_NAME");
          String pkColumnName = rsFk.getString("PKCOLUMN_NAME");
          String fkColumnName = rsFk.getString("FKCOLUMN_NAME");

          int fkSequence = rsFk.getInt("KEY_SEQ");
          System.out.println(
              tableName + "." + fkColumnName + " => " + pkTableName + "." + pkColumnName);
          hashFk.put(fkColumnName, pkColumnName);
          hashFk.put(fkColumnName + "_table", pkTableName);
        }
        rsFk.close();

        // create form page
        System.out.println(
            "Creating form page for "
                + tableName
                + " from table + "
                + application.config.Database.DB
                + "."
                + tableName);
        fDir = new File("../../web/WEB-INF/views/" + tableName);
        if (!fDir.exists()) fDir.mkdir();
        File f = new File("../../web/WEB-INF/views/" + tableName + "/form_" + tableName + ".jsp");
        if (ignoreList.get("form_" + tableName + ".jsp") != null) {
          Logger.getLogger(GenerateForm.class.getName())
              .log(Level.INFO, "Ignoring creation of form_" + tableName + ".jsp");
        } else {
          Writer out = new FileWriter(f);
          out.write(
              "<%@ page contentType=\"text/html; charset=UTF-8\" language=\"java\" import=\"java.sql.*,recite18th.library.Db,application.config.Config,recite18th.library.Pagination\" %>");
          out.write("<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %>\n");
          out.write("<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\" %>\n");

          // create model for this class, use in detecting its PK Field
          cl = Class.forName("application.models." + className + "Model");
          model = (Model) cl.newInstance();

          // iterate all columns
          resultSet.beforeFirst();
          resultSet.next();
          out.write(
              "<table border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#E8EDFF\">\n");
          out.write("<tr>\n");
          out.write("<td>\n");
          out.write(
              "<form action=\"<%=Config.base_url%>index/"
                  + className
                  + "/save\" method=\"post\" enctype=\"multipart/form-data\">\n"); // I hope it's
          // okay to
          // default it to
          // multipart data
          out.write("<table id=\"hor-zebra\" summary=\"Form " + className + "\">\n");
          out.write("<thead>\n");
          out.write("<tr>\n");
          out.write("<th colspan=\"2\" class=\"odd\" scope=\"col\">Form " + className + " </th>\n");
          out.write("</tr>\n");
          out.write("</thead>\n");
          out.write("<tbody>\n");

          for (int i = 1; i <= nColoumn; i++) {
            String columnName = metaColumn.getColumnName(i);
            String dataType = metaColumn.getColumnClassName(i);
            out.write("<tr>\n");

            // if(!columnName.equals(model.getPkFieldName())) // implementing the case of PK not
            // AutoIncrement
            // if(!metaColumn.isAutoIncrement(i))
            // {
            // varying field input for type

            // foreign field, as chooser page view
            if (hashFk.get(columnName)
                != null) // TODO: what if PK is chooser also?? :) CUrrently I add it manually the
            // hidden_*Pk_nama* field
            {
              String fkTableName = hashFk.get(columnName + "_table") + "";
              String fkColumnName = hashFk.get(columnName) + "";
              String fkController = StringUtil.toProperClassName(fkTableName);

              out.write("<td>" + columnName + "</td>\n");
              out.write("<td>\n");
              out.write(
                  "<input name=\""
                      + columnName
                      + "\" type=\"hidden\" id=\""
                      + columnName
                      + "\" value=\"${model."
                      + columnName
                      + "}\"/>\n");
              out.write(
                  "<input name=\"label_"
                      + columnName
                      + "\" readonly=\"true\" type=\"text\" id=\"label_"
                      + columnName
                      + "\" value=\"${model."
                      + columnName
                      + "}\"/>\n"); // TODO : translate I
              out.write(
                  "<a href=\"<%=Config.base_url%>index/"
                      + fkController
                      + "/chooseView?height=220&width=700\" class=\"thickbox\">Pilih</a>");
              out.write("</td>\n");
            } else {

              // regular field input, not foreign key case
              if (!columnName.equals(model.getPkFieldName())) {
                out.write("<td>" + columnName + "</td>\n");
                out.write("<td>\n");

                // ENUM Column, displayed as HTML SELECT. May will only work for mysql only...
                Logger.getLogger(GenerateForm.class.getName())
                    .log(Level.INFO, columnName + " type is " + metaColumn.getColumnType(i));
                if (metaColumn.getColumnType(i) == 1) {
                  String enum_content[][] =
                      Db.getDataSet(
                          "SELECT SUBSTRING(COLUMN_TYPE,6,length(SUBSTRING(COLUMN_TYPE,6))-1) as enum_content "
                              + " FROM information_schema.COLUMNS "
                              + " WHERE TABLE_NAME='"
                              + tableName
                              + "' "
                              + " AND COLUMN_NAME='"
                              + columnName
                              + "'");
                  if (enum_content.length > 0) {
                    // Logger.getLogger(Model.class.getName()).log(Level.INFO, "Enum Content = " +
                    // enum_content[0][0]);
                    String enum_list[] = enum_content[0][0].split(",");
                    out.write("<select name=\"" + columnName + "\" id=\"" + columnName + "\">\n");
                    for (int ienum_list = 0; ienum_list < enum_list.length; ienum_list++)
                      out.write(
                          "\t<option <c:if test=\"${model."
                              + columnName
                              + "=='"
                              + enum_list[ienum_list].substring(
                                  1, enum_list[ienum_list].length() - 1)
                              + "'}\"> selected=\"selected\" </c:if> value=\""
                              + enum_list[ienum_list].substring(
                                  1, enum_list[ienum_list].length() - 1)
                              + "\">"
                              + enum_list[ienum_list].substring(
                                  1, enum_list[ienum_list].length() - 1)
                              + "</option>\n");
                    out.write("</select>\n\n");

                  } else {
                    // no enum content detected.. :)
                    out.write(
                        "<input name=\""
                            + columnName
                            + "\" type=\"text\" id=\""
                            + columnName
                            + "\" value=\"${model."
                            + columnName
                            + "}\"/>\n");
                  }
                } else if (metaColumn.getColumnType(i) == 91) {
                  out.write(
                      "<input name=\""
                          + columnName
                          + "\" type=\"text\" id=\""
                          + columnName
                          + "\" value=\"${model."
                          + columnName
                          + "}\"/>\n");
                  out.write("<script>\n");
                  out.write(
                      " if(!isValidDate($('#"
                          + columnName
                          + "').val())) $('#"
                          + columnName
                          + "').val('1980-1-1');\n"); // TODO: default value
                  out.write("  (function($){\n");

                  out.write("  $('#" + columnName + "').click(function() {\n");
                  out.write("    $('#" + columnName + "').DatePickerShow();\n");
                  out.write("  });\n");

                  out.write("  $('#" + columnName + "').DatePicker({\n");
                  out.write("    format:'Y-m-d',\n");
                  out.write("    date: $('#" + columnName + "').val(),\n");
                  out.write("    current: $('#" + columnName + "').val(),\n");
                  out.write("    starts: 1,\n");
                  out.write("    position: 'r',\n");

                  out.write("    onBeforeShow: function(){\n");
                  out.write(
                      "      $('#"
                          + columnName
                          + "').DatePickerSetDate($('#"
                          + columnName
                          + "').val(), true);\n");
                  out.write("    },\n");

                  out.write("    onChange: function(formated, dates){\n");
                  out.write("      $('#" + columnName + "').DatePickerHide();\n");
                  out.write("      $('#" + columnName + "').val(formated);\n");
                  out.write("    }\n");
                  out.write("  });\n");
                  out.write("  })(jQuery)\n");
                  out.write(" </script>\n");
                } else {
                  out.write(
                      "<input name=\""
                          + columnName
                          + "\" type=\"text\" id=\""
                          + columnName
                          + "\" value=\"${model."
                          + columnName
                          + "}\"/>\n");
                  out.write("${" + columnName + "_error}\n"); // regular input field
                }
              } else { // PK case
                if (metaColumn.isAutoIncrement(i)) {
                  out.write(
                      "<input name=\"hidden_"
                          + columnName
                          + "\" type=\"hidden\" id=\"hidden_"
                          + columnName
                          + "\" value=\"${model."
                          + columnName
                          + "}\"/>\n");
                } else {
                  out.write("<td>" + columnName + "</td>\n");
                  out.write("<td>\n");

                  out.write(
                      "<input name=\""
                          + columnName
                          + "\" type=\"text\" id=\""
                          + columnName
                          + "\" value=\"${model."
                          + columnName
                          + "}\"/>\n");
                  out.write("${" + columnName + "_error}\n");
                  out.write(
                      "<input name=\"hidden_"
                          + columnName
                          + "\" type=\"hidden\" id=\"hidden_"
                          + columnName
                          + "\" value=\"${model."
                          + columnName
                          + "}\"/>\n");
                }
              }
              out.write("</td>\n");
            }
            out.write("</tr>\n");
          }
          out.write("<tr class=\"odd\">\n");
          out.write("<td>&nbsp;</td>\n");
          out.write("<td><input type=\"submit\" name=\"Submit\" value=\"Simpan\">");
          out.write(
              "<input name=\"Button\" type=\"button\" id=\"Submit\" value=\"Batal\" onClick=\"javascript:history.back(-1);\"></td>\n");
          out.write("</tr>\n");
          out.write("</tbody>\n");
          out.write("</table>\n");
          out.write("</form></td>\n");
          out.write("</tr>\n");
          out.write("</table>\n");
          out.flush();
          out.close();
        }

        // create viewPage
        if (ignoreList.get("view_" + tableName + ".jsp") != null) {
          Logger.getLogger(GenerateForm.class.getName())
              .log(Level.INFO, "Ignoring creation of view_" + tableName + ".jsp");
        } else {
          System.out.println("Creating view page " + tableName);

          fDir = new File("../../web/WEB-INF/views/" + tableName);
          if (!fDir.exists()) fDir.mkdir();
          File fView =
              new File("../../web/WEB-INF/views/" + tableName + "/view_" + tableName + ".jsp");
          Writer outView = new FileWriter(fView);
          outView.write(
              "<%@ page contentType=\"text/html; charset=UTF-8\" language=\"java\" import=\"java.sql.*,recite18th.library.Db,application.config.Config,recite18th.library.Pagination\" %>");
          outView.write("<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %>\n");
          outView.write(
              "<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\" %>\n");
          outView.write("<% int pagenum = 0; %>\n");
          // outView.write("<%@ include file=\"/WEB-INF/views/header.jsp\" %>");
          outView.write(
              "<a href=\"<%=Config.base_url%>index/" + className + "/input/-1\">Tambah Data</a>\n");
          outView.write(
              "|| <a href=\"<%=Config.base_url%>index/" + className + "/print\">Cetak</a>\n");
          outView.write("<table width=\"100%\" id=\"rounded-corner\">\n");
          outView.write("<thead>\n");
          // iterate all columns : table header
          outView.write("  <tr>\n");
          outView.write("  <th scope=\"col\" class=\"rounded-company\">No.</th>\n");
          resultSet.beforeFirst();
          resultSet.next();

          // get Primary Key Field Name : often use
          String pkFieldName = "";
          try {
            Class params[] = null;
            Method objMethod = cl.getMethod("getPkFieldName", params);
            pkFieldName = "" + objMethod.invoke(model);
          } catch (Exception ex) {
            Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
          }

          // ALL Lower Case
          pkFieldName = pkFieldName.toLowerCase();

          // customize column view page
          for (int i = 1; i <= nColoumn; i++) {
            String columnName =
                metaColumn.getColumnName(i).toLowerCase(); // Caution : ALL LowerCase
            String dataType = metaColumn.getColumnClassName(i);
            String thClass = "rounded-q1";
            String thTitle = StringUtil.toProperFieldTitle(columnName);

            if (TableCustomization.getTable(tableName)
                != null) // there is customization for this table
            {
              if (TableCustomization.getTable(tableName).get(columnName) != null) {
                thTitle = TableCustomization.getTable(tableName).get(columnName) + "";
                outView.write(
                    "  <th scope=\"col\" class=\"" + thClass + "\">" + thTitle + "</th>\n");
              }
            } else { // standard view for this table : hide PK, because mostly is auto increment
              if (!metaColumn.isAutoIncrement(i))
                outView.write(
                    "  <th scope=\"col\" class=\"" + thClass + "\">" + thTitle + "</th>\n");
            }
          }

          outView.write("  <th scope=\"col\" class=\"rounded-q4\">Aksi</th>\n");
          outView.write("  </tr>\n");
          outView.write("</thead>\n");
          outView.write("<tfoot>\n");
          outView.write("  <tr>\n");
          outView.write(
              "    <td colspan=\""
                  + (nColoumn + 1)
                  + "\" class=\"rounded-foot-left\"><%=Pagination.createLinks(pagenum)%></td>\n");
          outView.write("    <td class=\"rounded-foot-right\">&nbsp;</td>\n");
          outView.write("  </tr>\n");
          outView.write("</tfoot>\n");

          outView.write("<tbody>\n");
          outView.write("  <c:forEach items=\"${row}\" var=\"item\" varStatus=\"status\" >\n");
          outView.write("    <tr>\n");
          outView.write("      <td>${status.count}</td>\n");

          // iterate all columns : table data
          resultSet.beforeFirst();
          resultSet.next();
          for (int i = 1; i <= nColoumn; i++) {
            String columnName = metaColumn.getColumnName(i);
            // if(!columnName.equals(pkFieldName)) //TOFIX : currently, PK Field is not shown
            if (TableCustomization.getTable(tableName) != null) {
              if (TableCustomization.getTable(tableName).get(columnName) != null) {
                outView.write("      <td>${item." + columnName + "}</td>\n");
              }
            } else {
              if (!metaColumn.isAutoIncrement(i))
                outView.write("      <td>${item." + columnName + "}</td>\n");
            }
          }

          outView.write("      <td>\n");
          outView.write(
              "         <a href=\"<%=Config.base_url%>index/"
                  + className
                  + "/input/${item."
                  + pkFieldName
                  + "}\">Ubah</a>\n");
          outView.write(
              "         <a href=\"<%=Config.base_url%>index/"
                  + className
                  + "/delete/${item."
                  + pkFieldName
                  + "}\" onClick=\"return confirm('Apakah Anda yakin?');\">Hapus</a>\n");
          outView.write("      </td>\n");

          outView.write("    </tr>\n");
          outView.write("  </c:forEach>\n");
          outView.write("</tbody>\n");
          outView.write("</table>\n");
          // outView.write("<%@ include file=\"/WEB-INF/views/footer.jsp\" %>");
          outView.flush();
          outView.close();
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }