Guest User

Untitled

a guest
Aug 7th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. JSF PrimeFaces lose data and session
  2. import authentication.AuthenticatorManagerLocal;
  3. import javax.ejb.EJB;
  4. import javax.enterprise.context.SessionScoped;
  5. import javax.faces.bean.ApplicationScoped;
  6. import javax.faces.bean.ManagedBean;
  7. import javax.faces.bean.RequestScoped;
  8.  
  9. @ManagedBean
  10. @SessionScoped
  11. public class UserMB {
  12. @EJB
  13. private AuthenticatorManagerLocal authenticatorManager;
  14.  
  15. /** Creates a new instance of UserMB */
  16. public UserMB() {
  17. }
  18.  
  19. Boolean isUserLoggedIn;
  20. String username;
  21. String password;
  22. String nickName;
  23.  
  24. public String getNickName() {
  25. nickName="vanessa";
  26. return nickName;
  27. }
  28.  
  29. public void setNickName(String nickName) {
  30. this.nickName = nickName;
  31. }
  32.  
  33. public Boolean getIsUserLoggedIn() {
  34. return isUserLoggedIn;
  35. }
  36.  
  37. public void setIsUserLoggedIn(Boolean isUserLoggedIn) {
  38. this.isUserLoggedIn = isUserLoggedIn;
  39. }
  40.  
  41. public String getPassword() {
  42. return password;
  43. }
  44.  
  45. public void setPassword(String password) {
  46. this.password = password;
  47. }
  48.  
  49. public String getUsername() {
  50. return username;
  51. }
  52.  
  53. public void setUsername(String username) {
  54. this.username = username;
  55. }
  56.  
  57. public String authenticateUser(){
  58. isUserLoggedIn= authenticatorManager.authenticateUser(username, password);
  59. if(isUserLoggedIn)return "Home";
  60. else
  61. return null;
  62. }
  63.  
  64. public void logout(){
  65. isUserLoggedIn=false;
  66. username="";
  67. password="";
  68. }
  69.  
  70. public String goToIndex(){
  71. return "Index";
  72. }
  73.  
  74. }
  75.  
  76. <p:commandButton value="SearchCB" action="#{expSearchResultsMB.search()}" ajax="false" />
  77.  
  78. <h:outputLabel value="#{userMB.username}" />
  79.  
  80. import javax.enterprise.context.SessionScoped;
  81.  
  82. import javax.faces.bean.SessionScoped;
Add Comment
Please, Sign In to add comment