/* (non-Javadoc)
  * @see com.code.aon.ui.form.event.ControllerAdapter#beforeBeanUpdated(com.code.aon.ui.form.event.ControllerEvent)
  */
 @Override
 public void beforeBeanUpdated(ControllerEvent event) throws ControllerListenerException {
   UserController uc = (UserController) event.getController();
   User user = (User) uc.getTo();
   UserManager userManager = uc.getUserManager();
   String name = user.getName();
   name = (name.equals(userManager.getUser().getName())) ? userManager.getUser().getName() : name;
   String password = userManager.getPassword();
   if (password == null
       || password.equals("")
       || password.equals(userManager.getUser().getPasswd())) {
     userManager.setChangePassword(false);
   } else {
     userManager.setChangePassword(true);
   }
   userManager.setName(name);
   try {
     userManager.accept(null);
     user.setLogin(userManager.getId());
   } catch (MaximumLoginException e) {
     FacesContext ctx = FacesContext.getCurrentInstance();
     ResourceBundle bundle =
         ResourceBundle.getBundle(IOperation.MESSAGES_FILE, ctx.getViewRoot().getLocale());
     MessageFormat mf = new MessageFormat(bundle.getString(e.getMessage()));
     throw new ControllerListenerException(mf.format(new Object[] {e.getArg()}), e);
   }
 }
 /**
  * Prepares password changing proccess.
  *
  * @param userManager
  */
 private void changePassword(UserManager userManager) {
   userManager.setChangePassword(true);
   userManager.setNewPassword(userManager.getPassword());
   userManager.setConfirmPassword(userManager.getPassword());
   userManager.setPassword(userManager.getUser().getPasswd());
 }