Advertisement
Guest User

update account

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