Exemple #1
0
  /*
   * (non-Javadoc)
   * @see net.rrm.ehour.persistence.persistence.ui.admin.BaseTabbedAdminPage#getNewAddBackingBean()
   */
  @Override
  protected UserBackingBean getNewAddBaseBackingBean() {
    UserBackingBean userBean;

    userBean = new UserBackingBean(new User(), AdminAction.NEW);
    userBean.getUser().setActive(true);

    return userBean;
  }
  @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);
    }
  }
 private void deleteUser(UserBackingBean userBackingBean) {
   userService.deleteUser(userBackingBean.getUser().getUserId());
 }