Guest User

Untitled

a guest
Mar 23rd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <h:form>
  2. <h1>Регистрация</h1>
  3. <h:panelGrid columns="3">
  4. <h:outputLabel for="email" value="Email: " />
  5. <h:inputText id="email" value="#{userBean.email}" required="true" />
  6. <h:message for="email" />
  7.  
  8. <h:outputLabel for="password" value="Пароль: " />
  9. <h:inputSecret id="password" value="#{userBean.password}" required="true" />
  10. <h:message for="password" />
  11.  
  12. <h:commandButton value="Зарегестрировать" action="#{userBean.registrate()}" />
  13. <h:button value="Войти" outcome="login" />
  14. <br />
  15. </h:panelGrid>
  16. </h:form>
  17.  
  18. @Named
  19. @SessionScoped
  20. public class UserBean implements Serializable {
  21.  
  22. @Inject
  23. private UserEJB userEJB;
  24.  
  25. private String email;
  26. private String password;
  27. private User currentUser;
  28.  
  29. public User getCurrentUser() {
  30. return currentUser;
  31. }
  32.  
  33. public void setCurrentUser(User currentUser) {
  34. this.currentUser = currentUser;
  35. }
  36.  
  37. public String getEmail() {
  38. return email;
  39. }
  40.  
  41. public void setEmail(String email) {
  42. this.email = email;
  43. }
  44.  
  45. public String getPassword() {
  46. return password;
  47. }
  48.  
  49. public void setPassword(String password) {
  50. this.password = password;
  51. }
  52.  
  53. public String registrate() {
  54. User user = new User();
  55. user.setEmail(email);
  56. user.setPassword(password);
  57. currentUser = user;
  58.  
  59. userEJB.create(user);
  60. return "index";
  61. }
  62. }
Add Comment
Please, Sign In to add comment