예제 #1
0
  public void doLogin(
      @FormGroup("login") User user,
      @FormField(name = "loginError", group = "login") CustomErrors err,
      @Param("Done") String url,
      Navigator nav,
      HttpSession session,
      ParameterParser params)
      throws Exception {

    user = userService.login(user.getName(), SecurityUtils.getPassword(user.getPassword()));

    if (user != null) {
      // 在session中创建User对象
      session.setAttribute(WebConstant.USER_SESSION_KEY, user);

      // 跳转到return页面
      if (null == url) {
        nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
      } else {
        nav.redirectToLocation(url);
      }

    } else {
      err.setMessage("invalidUserOrPassword");
    }
  }
예제 #2
0
  public void doEdit(
      @FormGroup("editUserInfo") Group userInfo,
      @Param("pageIndex") int pageIndex,
      @Param("searchKey") String searchKey,
      Navigator nav,
      @FormField(name = "formUserError", group = "editUserInfo") CustomErrors err) {
    User user = new User();
    userInfo.setProperties(user);
    if (null != user.getPassword()) {
      if (user.getPassword().length() < 6) {
        err.setMessage("passwordTooLess");
        return;
      }
      user.setPassword(SecurityUtils.getPassword(user.getPassword()));
    }

    try {
      userService.updataUser(user);
    } catch (RepeatConfigureException rce) {
      err.setMessage("invalidUser");
      return;
    }
    nav.redirectToLocation(
        "userManager.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
  }
예제 #3
0
 public void doDelete(
     @Param("userId") Long userId,
     @Param("pageIndex") int pageIndex,
     @Param("searchKey") String searchKey,
     Navigator nav)
     throws WebxException {
   userService.deleteUser(userId);
   nav.redirectToLocation(
       "userManager.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
 }
예제 #4
0
  /**
   * 找到单个Channel,用于编辑Channel信息界面加载信息
   *
   * @param channelId
   * @param context
   * @throws WebxException
   */
  public void execute(
      @Param("userId") Long userId,
      @Param("pageIndex") int pageIndex,
      @Param("searchKey") String searchKey,
      Context context,
      Navigator nav)
      throws Exception {
    User user = userService.findUserById(userId);

    context.put("user", user);
    context.put("pageIndex", pageIndex);
    context.put("searchKey", searchKey);
  }
예제 #5
0
 public void doAdd(
     @FormGroup("addUserInfo") Group userInfo,
     Navigator nav,
     @FormField(name = "formUserError", group = "addUserInfo") CustomErrors err) {
   User user = new User();
   userInfo.setProperties(user);
   user.setPassword(SecurityUtils.getPassword(user.getPassword()));
   try {
     userService.createUser(user);
   } catch (RepeatConfigureException rce) {
     err.setMessage("invalidUser");
     return;
   }
   nav.redirectTo(WebConstant.USER_MANAGER_LINK);
 }