Advertisement
Guest User

update account in account manager

a guest
Apr 30th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. /*
  2. Update the signed-in user's account profile. Return "" if an error occurs;w
  3. otherwise, upon successful account update, redirect to show the Profile page.
  4. */
  5.  
  6. public String updateAccount() throws Exception {
  7.  
  8. if (statusMessage == null || statusMessage.isEmpty()) {
  9.  
  10. // Obtain the signed-in user's username
  11. String user_name = (String) FacesContext.getCurrentInstance().
  12. getExternalContext().getSessionMap().get("username");
  13.  
  14. // Obtain the object reference of the signed-in user
  15. Responder editResponder = getResponderFacade().findByUsername(user_name);
  16.  
  17. try {
  18. /*
  19. Set the signed-in user's properties to the values entered by
  20. the user in the EditAccountProfileForm in EditAccount.xhtml.
  21. */
  22. editResponder.setResponderName(this.selected.getResponderName());
  23. editResponder.setEmail(this.selected.getEmail());
  24. editResponder.setLocationName(this.selected.getLocationId().getLocationName());
  25. editResponder.setUsername(this.selected.getUsername());
  26. // Location userLocation = getLatLongFromAddress(city, state, zipcode);
  27. // editResponder.setLocationId(userLocation);
  28.  
  29. // It is optional for the user to change his/her password
  30. String new_Password = getNewPassword();
  31.  
  32. if (new_Password == null || new_Password.isEmpty()) {
  33. // Do nothing. The user does not want to change the password.
  34. } else {
  35. editResponder.setPassword(new_Password);
  36. // Password changed successfully!
  37. // Password was first validated by invoking the validatePasswordChange method below.
  38. }
  39.  
  40. // Store the changes in the CloudDriveDB database
  41. getResponderFacade().edit(editResponder);
  42.  
  43. } catch (EJBException e) {
  44. username = "";
  45. statusMessage = "Something went wrong while editing user's profile! See: " + e.getMessage();
  46. return "";
  47. }
  48. // Account update is completed, redirect to show the Profile page.
  49. return "Profile.xhtml?faces-redirect=true";
  50. }
  51. return "";
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement