コード例 #1
0
  private void _jspService(
      javax.servlet.http.HttpServletRequest request,
      javax.servlet.http.HttpServletResponse response,
      com.caucho.jsp.PageContextImpl pageContext,
      javax.servlet.ServletContext application,
      javax.servlet.http.HttpSession session,
      TagState _jsp_state)
      throws Throwable {
    javax.servlet.jsp.JspWriter out = pageContext.getOut();
    final javax.el.ELContext _jsp_env = pageContext.getELContext();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    javax.servlet.jsp.tagext.JspTag _jsp_parent_tag = null;
    com.caucho.jsp.PageContextImpl _jsp_parentContext = pageContext;
    response.setContentType("text/html");
    response.setCharacterEncoding("utf-8");

    out.write(_jsp_string0, 0, _jsp_string0.length);
    CP_Classes.EthnicGroup ethnic;
    synchronized (pageContext.getSession()) {
      ethnic = (CP_Classes.EthnicGroup) pageContext.getSession().getAttribute("ethnic");
      if (ethnic == null) {
        ethnic = new CP_Classes.EthnicGroup();
        pageContext.getSession().setAttribute("ethnic", ethnic);
      }
    }
    out.write(_jsp_string1, 0, _jsp_string1.length);
    CP_Classes.Login logchk;
    synchronized (pageContext.getSession()) {
      logchk = (CP_Classes.Login) pageContext.getSession().getAttribute("logchk");
      if (logchk == null) {
        logchk = new CP_Classes.Login();
        pageContext.getSession().setAttribute("logchk", logchk);
      }
    }
    out.write(_jsp_string1, 0, _jsp_string1.length);
    CP_Classes.Translate trans;
    synchronized (pageContext.getSession()) {
      trans = (CP_Classes.Translate) pageContext.getSession().getAttribute("trans");
      if (trans == null) {
        trans = new CP_Classes.Translate();
        pageContext.getSession().setAttribute("trans", trans);
      }
    }
    out.write(_jsp_string1, 0, _jsp_string1.length);
    // added to check whether organisation is a consulting company
    // Mark Oei 09 Mar 2010
    out.write(_jsp_string1, 0, _jsp_string1.length);
    CP_Classes.Organization Org;
    synchronized (pageContext.getSession()) {
      Org = (CP_Classes.Organization) pageContext.getSession().getAttribute("Org");
      if (Org == null) {
        Org = new CP_Classes.Organization();
        pageContext.getSession().setAttribute("Org", Org);
      }
    }
    out.write(_jsp_string1, 0, _jsp_string1.length);
    CP_Classes.Create_Edit_Survey CE_Survey;
    synchronized (pageContext.getSession()) {
      CE_Survey =
          (CP_Classes.Create_Edit_Survey) pageContext.getSession().getAttribute("CE_Survey");
      if (CE_Survey == null) {
        CE_Survey = new CP_Classes.Create_Edit_Survey();
        pageContext.getSession().setAttribute("CE_Survey", CE_Survey);
      }
    }
    out.write(_jsp_string2, 0, _jsp_string2.length);
    // by lydia Date 05/09/2008 Fix jsp file to support Thai language
    out.write(_jsp_string3, 0, _jsp_string3.length);
    out.print((trans.tslt("Delete Ethnic Group")));
    out.write(_jsp_string4, 0, _jsp_string4.length);
    out.print((trans.tslt("Edit Ethnic Group")));
    out.write(_jsp_string5, 0, _jsp_string5.length);
    out.print((trans.tslt("Please enter Ethnic Group")));
    out.write(_jsp_string6, 0, _jsp_string6.length);
    out.print((trans.tslt("Add Ethnic Group")));
    out.write(_jsp_string7, 0, _jsp_string7.length);
    out.print((trans.tslt("Please enter Ethnic Group")));
    out.write(_jsp_string8, 0, _jsp_string8.length);

    String username = (String) session.getAttribute("username");

    if (!logchk.isUsable(username)) {
      out.write(_jsp_string9, 0, _jsp_string9.length);
    } else {

      if (request.getParameter("proceed") != null) {
        int PKOrg = new Integer(request.getParameter("proceed")).intValue();
        logchk.setOrg(PKOrg);
      }

      if (request.getParameter("Delete") != null) {

        int Ethnic_ID = new Integer(request.getParameter("ethnic_ID")).intValue();
        boolean bIsDeleted = ethnic.deleteRecord(Ethnic_ID, logchk.getPKUser());

        if (bIsDeleted) {

          out.write(_jsp_string10, 0, _jsp_string10.length);
        }
      }

      if (request.getParameter("Edit") != null) {
        int Ethnic_ID = new Integer(request.getParameter("ethnic_ID")).intValue();

        String txtEthnic = request.getParameter("txtEthnic");
        boolean bIsEdited =
            ethnic.editRecord(Ethnic_ID, txtEthnic, logchk.getOrg(), logchk.getPKUser());

        if (bIsEdited) {

          out.write(_jsp_string11, 0, _jsp_string11.length);

        } else {

          out.write(_jsp_string12, 0, _jsp_string12.length);
        }
      }

      if (request.getParameter("Add") != null) {

        String txtEthnic = request.getParameter("txtEthnic");

        boolean bExist = ethnic.existRecord(txtEthnic, logchk.getOrg());

        if (!bExist) {
          boolean bIsAdded = ethnic.addRecord(txtEthnic, logchk.getOrg(), logchk.getPKUser());

          if (bIsAdded) {

            out.write(_jsp_string13, 0, _jsp_string13.length);
          }
        } else {

          out.write(_jsp_string14, 0, _jsp_string14.length);
        }
      }

      out.write(_jsp_string15, 0, _jsp_string15.length);
      out.print((trans.tslt("Ethnic Group")));
      out.write(_jsp_string16, 0, _jsp_string16.length);
      out.print((trans.tslt("To Add, click on the Add button")));
      out.write(_jsp_string17, 0, _jsp_string17.length);
      out.print(
          (trans.tslt("To Edit, click on the relevant radio button and click on the Edit button")));
      out.write(_jsp_string17, 0, _jsp_string17.length);
      out.print(
          (trans.tslt(
              "To Delete, click on the relevant radio button and click on the Delete button")));
      out.write(_jsp_string18, 0, _jsp_string18.length);
      out.print((trans.tslt("Organisation")));
      out.write(_jsp_string19, 0, _jsp_string19.length);

      // Added to check whether organisation is also a consulting company
      // if yes, will display a dropdown list of organisation managed by this company
      // else, it will display the current organisation only
      // Mark Oei 09 Mar 2010
      String[] UserDetail = new String[14];
      UserDetail = CE_Survey.getUserDetail(logchk.getPKUser());
      boolean isConsulting = true;
      isConsulting =
          Org.isConsulting(UserDetail[10]); // check whether organisation is a consulting company
      if (isConsulting) {
        Vector vOrg = logchk.getOrgList(logchk.getCompany());

        for (int i = 0; i < vOrg.size(); i++) {
          votblOrganization vo = (votblOrganization) vOrg.elementAt(i);
          int PKOrg = vo.getPKOrganization();
          String OrgName = vo.getOrganizationName();

          if (logchk.getOrg() == PKOrg) {
            out.write(_jsp_string20, 0, _jsp_string20.length);
            out.print((PKOrg));
            out.write(_jsp_string21, 0, _jsp_string21.length);
            out.print((OrgName));
            out.write(_jsp_string22, 0, _jsp_string22.length);
          } else {
            out.write(_jsp_string20, 0, _jsp_string20.length);
            out.print((PKOrg));
            out.write('>');
            out.print((OrgName));
            out.write(_jsp_string22, 0, _jsp_string22.length);
          }
        }
      } else {
        out.write(_jsp_string23, 0, _jsp_string23.length);
        out.print((logchk.getSelfOrg()));
        out.write('>');
        out.print((UserDetail[10]));
        out.write(_jsp_string24, 0, _jsp_string24.length);
      } // End of isConsulting
      out.write(_jsp_string25, 0, _jsp_string25.length);
      out.print((trans.tslt("Ethnic Group")));
      out.write(_jsp_string26, 0, _jsp_string26.length);

      /** ****************** Edited by James 17 Oct 2007 ********************** */
      Vector v = ethnic.getAllEthnics(logchk.getOrg());

      for (int i = 0; i < v.size(); i++) {
        voEthnic vo = (voEthnic) v.elementAt(i);

        int ethnic_ID = vo.getPKEthnic();
        String ethnic_Desc = vo.getEthnicDesc();

        out.write(_jsp_string27, 0, _jsp_string27.length);
        out.print((ethnic_ID));
        out.write(_jsp_string28, 0, _jsp_string28.length);
        out.print((ethnic_Desc));
        out.write(_jsp_string29, 0, _jsp_string29.length);
        out.print((ethnic_Desc));
        out.write(_jsp_string30, 0, _jsp_string30.length);
      }

      out.write(_jsp_string31, 0, _jsp_string31.length);
      out.print((trans.tslt("Ethnic Group")));
      out.write(_jsp_string32, 0, _jsp_string32.length);
      out.print((trans.tslt("Add")));
      out.write(_jsp_string33, 0, _jsp_string33.length);
      out.print((trans.tslt("Edit")));
      out.write(_jsp_string34, 0, _jsp_string34.length);
      out.print((trans.tslt("Delete")));
      out.write(_jsp_string35, 0, _jsp_string35.length);
    }
    out.write(_jsp_string36, 0, _jsp_string36.length);
    // by lydia Date 05/09/2008 Fix jsp file to support Thai language
    out.write(_jsp_string37, 0, _jsp_string37.length);

    Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);

    out.write(_jsp_string38, 0, _jsp_string38.length);
    // Denise 05/01/2010 update new email address
    out.write(_jsp_string39, 0, _jsp_string39.length);
    out.print((year));
    out.write(_jsp_string40, 0, _jsp_string40.length);
  }
コード例 #2
0
  private void _jspService(
      javax.servlet.http.HttpServletRequest request,
      javax.servlet.http.HttpServletResponse response,
      com.caucho.jsp.PageContextImpl pageContext,
      javax.servlet.ServletContext application,
      javax.servlet.http.HttpSession session,
      TagState _jsp_state)
      throws Throwable {
    javax.servlet.jsp.JspWriter out = pageContext.getOut();
    final javax.el.ELContext _jsp_env = pageContext.getELContext();
    javax.servlet.ServletConfig config = getServletConfig();
    javax.servlet.Servlet page = this;
    javax.servlet.jsp.tagext.JspTag _jsp_parent_tag = null;
    com.caucho.jsp.PageContextImpl _jsp_parentContext = pageContext;
    response.setContentType("text/html");
    response.setCharacterEncoding("utf-8");

    out.write(_jsp_string0, 0, _jsp_string0.length);
    CP_Classes.Login logchk;
    synchronized (pageContext.getSession()) {
      logchk = (CP_Classes.Login) pageContext.getSession().getAttribute("logchk");
      if (logchk == null) {
        logchk = new CP_Classes.Login();
        pageContext.getSession().setAttribute("logchk", logchk);
      }
    }
    out.write(_jsp_string1, 0, _jsp_string1.length);
    CP_Classes.Create_Edit_Survey CE_Survey;
    synchronized (pageContext.getSession()) {
      CE_Survey =
          (CP_Classes.Create_Edit_Survey) pageContext.getSession().getAttribute("CE_Survey");
      if (CE_Survey == null) {
        CE_Survey = new CP_Classes.Create_Edit_Survey();
        pageContext.getSession().setAttribute("CE_Survey", CE_Survey);
      }
    }
    out.write(_jsp_string2, 0, _jsp_string2.length);
    CP_Classes.Translate trans;
    synchronized (pageContext.getSession()) {
      trans = (CP_Classes.Translate) pageContext.getSession().getAttribute("trans");
      if (trans == null) {
        trans = new CP_Classes.Translate();
        pageContext.getSession().setAttribute("trans", trans);
      }
    }
    out.write(_jsp_string2, 0, _jsp_string2.length);
    CP_Classes.RatingTask RT;
    synchronized (pageContext.getSession()) {
      RT = (CP_Classes.RatingTask) pageContext.getSession().getAttribute("RT");
      if (RT == null) {
        RT = new CP_Classes.RatingTask();
        pageContext.getSession().setAttribute("RT", RT);
      }
    }
    out.write(_jsp_string2, 0, _jsp_string2.length);
    CP_Classes.RatingScale RS;
    synchronized (pageContext.getSession()) {
      RS = (CP_Classes.RatingScale) pageContext.getSession().getAttribute("RS");
      if (RS == null) {
        RS = new CP_Classes.RatingScale();
        pageContext.getSession().setAttribute("RS", RS);
      }
    }
    out.write(_jsp_string2, 0, _jsp_string2.length);
    CP_Classes.Purpose PRP;
    synchronized (pageContext.getSession()) {
      PRP = (CP_Classes.Purpose) pageContext.getSession().getAttribute("PRP");
      if (PRP == null) {
        PRP = new CP_Classes.Purpose();
        pageContext.getSession().setAttribute("PRP", PRP);
      }
    }
    out.write(_jsp_string2, 0, _jsp_string2.length);
    CP_Classes.SurveyRating SVR;
    synchronized (pageContext.getSession()) {
      SVR = (CP_Classes.SurveyRating) pageContext.getSession().getAttribute("SVR");
      if (SVR == null) {
        SVR = new CP_Classes.SurveyRating();
        pageContext.getSession().setAttribute("SVR", SVR);
      }
    }
    out.write(_jsp_string3, 0, _jsp_string3.length);
    // by lydia Date 05/09/2008 Fix jsp file to support Thai language
    out.write(_jsp_string4, 0, _jsp_string4.length);
    out.print((trans.tslt("Please choose a rating task")));
    out.write(_jsp_string5, 0, _jsp_string5.length);

    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("expires", 0);

    String username = (String) session.getAttribute("username");
    if (!logchk.isUsable(username)) {
      out.write(_jsp_string6, 0, _jsp_string6.length);
    } else {

      if (request.getParameter("purpose") != null) {
        int var1 = new Integer(request.getParameter("purpose")).intValue();
        CE_Survey.setPurpose(var1);

        System.out.println("Purpose ID" + var1);
      } else {
        // Edited by Eric Lu 22/5/08
        // Resets purpose if first time accessing this page
        CE_Survey.setPurpose(0);
      }
      if (request.getParameter("add") != null) {
        String rating = "";
        String scale = "";
        boolean RequiredChosen = false;
        String[] chkSelect = new String[10];
        String[] ScaleDesc = new String[10];
        String[] radioSelect = new String[10];

        int SurveyID = CE_Survey.getSurvey_ID();
        ScaleDesc = request.getParameterValues("selScaleDesc");
        chkSelect = request.getParameterValues("chkRat");
        radioSelect = request.getParameterValues("radioRat");
        int count = 0; // count shifted, Mark Oei 16 April 2010

        /*------------------------------------------------- for checkbox ------------------------------------------------*/

        // Changed by Ha 28/05/09 to pop out message when action is done successfully
        if (chkSelect != null) {
          boolean added = false;
          count = 0; // change to declare variable outside if statement, Mark Oei 16 April 2010
          for (int i = 0; i < chkSelect.length; i++) {
            rating = chkSelect[i];

            if (rating != null) {

              String RatName = " ";
              RatName = RT.getRatingTask(Integer.parseInt(rating));

              ScaleDesc = new String[10];
              ScaleDesc = request.getParameterValues("selScaleDesc" + rating);
              for (int j = 0; j < ScaleDesc.length; j++) {
                scale = ScaleDesc[j];
                CE_Survey.editPurpose(SurveyID, CE_Survey.getPurpose());
                added = CE_Survey.addRating(SurveyID, scale, rating, RatName);
                if (added) count++;
              }
            }
          }
          // Added to insert default values into database when rating tasks are added
          // Mark Oei 16 April 2010
          int lLimit = 0;
          int uLimit = 0;
          int scaleRange = CE_Survey.getRatScale();

          int taskCount = (Integer) session.getAttribute("taskCount") + count;

          if ((taskCount == 1 && Integer.parseInt(rating) == 1)) {
            lLimit = scaleRange / 2 - 1;
            uLimit = scaleRange / 2 + 1;
          } else {
            lLimit = -1;
            uLimit = 1;
          }
          boolean isSuccessful = CE_Survey.setMinPassScore(SurveyID, lLimit, uLimit);
          if (isSuccessful) {
            System.out.println(
                "Default Limits " + lLimit + ", " + uLimit + " has been inserted successfully");
          }
          if (count == chkSelect.length) {
            out.write(_jsp_string7, 0, _jsp_string7.length);
          }
        }

        /*-------------------------------------------------------- for radiobox ----------------------------------------------*/

        rating = "";

        if (radioSelect != null) {
          for (int i = 0; i < radioSelect.length; i++) {
            rating = radioSelect[i];

            if (rating != null) {

              String RatName = RT.getRatingTask(Integer.parseInt(rating));

              ScaleDesc = new String[10];
              ScaleDesc = request.getParameterValues("selScaleDesc" + rating);
              for (int j = 0; j < ScaleDesc.length; j++) {
                scale = ScaleDesc[j];
                CE_Survey.addRating(SurveyID, scale, rating, RatName);
              }
            }
          }
        }

        out.write(_jsp_string8, 0, _jsp_string8.length);
      }

      out.write(_jsp_string9, 0, _jsp_string9.length);
      out.print((trans.tslt("To Select Rating Task, checked on the provided boxes under Select")));
      out.write(_jsp_string10, 0, _jsp_string10.length);
      out.print((trans.tslt("Purpose of Survey")));
      out.write(_jsp_string11, 0, _jsp_string11.length);
      out.print((trans.tslt("Choose one")));
      out.write(_jsp_string12, 0, _jsp_string12.length);

      Vector v = PRP.getAllPurpose();

      for (int i = 0; i < v.size(); i++) {
        votblPurpose vo = (votblPurpose) v.elementAt(i);
        int PurposeID = vo.getPurposeID();
        String PurposeName = vo.getPurposeName();

        if (CE_Survey.getPurpose() == PurposeID) {

          out.write(_jsp_string13, 0, _jsp_string13.length);
          out.print((PurposeID));
          out.write(_jsp_string14, 0, _jsp_string14.length);
          out.print((PurposeName));
          out.write(_jsp_string12, 0, _jsp_string12.length);
        } else {

          out.write(_jsp_string15, 0, _jsp_string15.length);
          out.print((PurposeID));
          out.write('>');
          out.print((PurposeName));
          out.write(_jsp_string12, 0, _jsp_string12.length);
        }
      }
      out.write(_jsp_string16, 0, _jsp_string16.length);
      out.print((trans.tslt("Scale Range Chosen")));
      out.write(_jsp_string17, 0, _jsp_string17.length);
      out.print((CE_Survey.getRatScale()));
      out.write(_jsp_string18, 0, _jsp_string18.length);
      out.print((trans.tslt("Rating Task")));
      out.write(_jsp_string19, 0, _jsp_string19.length);
      out.print((trans.tslt("Select")));
      out.write(_jsp_string20, 0, _jsp_string20.length);
      out.print((trans.tslt("Rating Task")));
      out.write(_jsp_string21, 0, _jsp_string21.length);
      out.print((trans.tslt("Scale Description")));
      out.write(_jsp_string22, 0, _jsp_string22.length);

      String query2 = "";
      boolean dunAddPR = false;

      int iRatingTaskID = SVR.getRatingTaskID(CE_Survey.getSurvey_ID());
      if (iRatingTaskID != 0) dunAddPR = true;

      boolean anyRecord = false;
      boolean anyscale = false;

      Vector vRT = RT.getRatingTask(CE_Survey.getSurvey_ID(), dunAddPR, CE_Survey.getPurpose());

      for (int i = 0; i < vRT.size(); i++) {
        anyRecord = true;
        votblRatingTask vo = (votblRatingTask) vRT.elementAt(i);
        int RatID = vo.getRatingTaskID();
        String RatName = vo.getRatingTask();
        String ScaleType = vo.getScaleType();

        out.write(_jsp_string23, 0, _jsp_string23.length);
        if (CE_Survey.getPurpose() != 9) {
          out.write(_jsp_string24, 0, _jsp_string24.length);
          out.print((RatID));
          out.write(_jsp_string25, 0, _jsp_string25.length);
        } else {
          if (RatID != 2 && RatID != 3) {
            out.write(_jsp_string26, 0, _jsp_string26.length);
            out.print((RatID));
            out.write(_jsp_string27, 0, _jsp_string27.length);
          } else {
            out.write(_jsp_string28, 0, _jsp_string28.length);
            out.print((RatID));
            out.write(_jsp_string29, 0, _jsp_string29.length);
          }
        }
        out.write(_jsp_string30, 0, _jsp_string30.length);
        out.print((RatName));
        out.write(_jsp_string31, 0, _jsp_string31.length);
        out.print(("selScaleDesc" + RatID));
        out.write(_jsp_string32, 0, _jsp_string32.length);

        Vector vScale =
            RS.getRatingScale(CE_Survey.getRatScale(), ScaleType, CE_Survey.get_survOrg());

        for (int j = 0; j < vScale.size(); j++) {
          votblScale voS = (votblScale) vScale.elementAt(j);
          anyscale = true;
          int ScaleID = voS.getScaleID();
          String ScaleDesc = voS.getScaleDescription();

          out.write(_jsp_string33, 0, _jsp_string33.length);
          out.print((ScaleID));
          out.write('>');
          out.print((ScaleDesc));
          out.write(_jsp_string34, 0, _jsp_string34.length);
        }
        out.write(_jsp_string35, 0, _jsp_string35.length);
      }

      if (anyRecord == false && CE_Survey.getPurpose() != 0) {

        out.write(_jsp_string36, 0, _jsp_string36.length);
        out.print(
            (trans.tslt("All the rating tasks under this purpose of survey have been added")));
        out.write(_jsp_string37, 0, _jsp_string37.length);
      }
      out.write(_jsp_string38, 0, _jsp_string38.length);
      if (anyRecord && anyscale) {

        out.write(_jsp_string39, 0, _jsp_string39.length);
        out.print((trans.tslt("Add")));
        out.write(_jsp_string40, 0, _jsp_string40.length);
      }
      out.write(_jsp_string41, 0, _jsp_string41.length);
      out.print((trans.tslt("Close")));
      out.write(_jsp_string42, 0, _jsp_string42.length);
    }
    out.write(_jsp_string43, 0, _jsp_string43.length);
  }