Пример #1
0
  @Override
  protected boolean processFormSubmit(
      AjaxRequestTarget target, AdminBackingBean backingBean, AjaxEventType type) throws Exception {
    UserManageBackingBean userManageBackingBean = (UserManageBackingBean) backingBean;

    boolean eventHandled;

    try {
      User user = userManageBackingBean.getUser();
      eventHandled = false;

      if (type == USER_CREATED) {
        userService.persistNewUser(user, user.getPassword());
      } else if (type == USER_UPDATED) {
        userService.persistEditedUser(user);

        String password = user.getPassword();
        if (StringUtils.isNotBlank(password)) {
          userService.changePassword(user.getUsername(), password);
        }
      } else if (type == USER_DELETED) {
        deleteUser(userManageBackingBean);
      }
    } catch (ObjectNotUniqueException obnu) {
      backingBean.setServerMessage(obnu.getMessage());
      target.add(this);
      eventHandled = true;
    }

    return !eventHandled;
  }
Пример #2
0
  @Override
  protected void processFormSubmit(
      AjaxRequestTarget target, AdminBackingBean backingBean, AjaxEventType type) throws Exception {
    UserBackingBean userBackingBean = (UserBackingBean) backingBean;

    if (type == UserEditAjaxEventType.USER_UPDATED) {
      if (userBackingBean.getAdminAction() == AdminAction.NEW) {
        userService.newUser(userBackingBean.getUser(), userBackingBean.getUser().getPassword());
      } else {
        userService.editUser(userBackingBean.getUser());

        String password = userBackingBean.getUser().getPassword();
        if (StringUtils.isNotBlank(password)) {
          userService.changePassword(userBackingBean.getUser().getUsername(), password);
        }
      }
    } else if (type == UserEditAjaxEventType.USER_DELETED) {
      deleteUser(userBackingBean);
    }
  }