Пример #1
0
  /* (non-Javadoc)
   * @see com.my.pro.common.basic.BasicAction#doInit(javax.servlet.http.HttpServletRequest)
   */
  @Override
  public ReplyBean doInit(BasicForm form, HttpServletRequest request) {
    UserSession user = WebControlHelper.getUserSession(request);
    List<TitleInfoBean> list = new ArrayList<TitleInfoBean>();

    list.add(testGetTitleInfoBean(true));
    list.add(testGetTitleInfoBean(true));
    list.add(testGetTitleInfoBean(true));
    list.add(testGetTitleInfoBean(false));
    list.add(testGetTitleInfoBean(false));
    list.add(testGetTitleInfoBean(false));

    if (user.isLoginFlg()) {
      ReplyManager reply = new ReplyManager();
      reply.setLoginFlg(true);
      reply.setInfoList(list);
      reply.setForward("manager");
      return reply;
    } else {
      ReplyManager reply = new ReplyManager();
      reply.setInfoList(list);
      reply.setLoginFlg(false);
      reply.setForward("manager");
      return reply;
    }
  }
Пример #2
0
  @Override
  public void doAjax(BasicForm form, HttpServletRequest request, HttpServletResponse response) {
    boolean loginFlg = false;
    LoginForm loginForm = (LoginForm) form;
    // Login Out
    if (!"login".equals(loginForm.getActionName())) {
      // Login Out
      WebControlHelper.resetUserSession(request);
    } else {
      // Login In
      LoginForm bean = (LoginForm) form;
      String sql =
          "select userid"
              + LN
              + ",name         "
              + LN
              + ",pwd          "
              + LN
              + ",rank         "
              + LN
              + ",validate     "
              + LN
              + "from passinfo "
              + LN
              + "where 1=1     "
              + LN
              + "and pwd='"
              + bean.getPwd().trim()
              + "'     "
              + LN
              + "and name='"
              + bean.getName().trim()
              + "'    "
              + LN
              + "order by userid";

      ResultSet rs = SQLHelper.inistance().query(sql);

      int userid = 0;
      int rank = -1;

      // Create Session
      try {
        if (rs.next()) {
          userid = rs.getInt(1);
          rank = rs.getInt(4);
          if (!rs.next()) {
            loginFlg = true;
          }
        }
      } catch (SQLException e1) {
        e1.printStackTrace();
      }

      SQLHelper.inistance().close();
    }

    WebControlHelper.getUserSession(request).setLoginFlg(loginFlg);

    String json = "{" + "\"" + "loginFlg" + "\"" + ":" + "\"" + (loginFlg ? 1 : 0) + "\"" + "}";
    System.out.println("json string =" + json);
    try {
      response.getWriter().write(json);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }