- the user bean (controller) needs to be updated after successful registration to bear the user id
- added new template register_done.xhtml
- removed companyName from bean as this will be handled differently
- added birthday property
- also doRegister() needs to return the updated user instance
- more language internationalized
- temporary set user account status to CONFIRMED for easier development
- many more other imrovements ... :-( I hit commit to quickly.
- updated jars
Signed-off-by:Roland Häder <roland@mxchange.org>
/**
* Reemote register session bean
*/
- private UserLoginSessionBeanRemote login;
+ private UserLoginSessionBeanRemote loginBean;
/**
* User controller
Context context = new InitialContext();
// Try to lookup
- this.login = (UserLoginSessionBeanRemote) context.lookup("ejb/stateless-login"); //NOI18N
+ this.loginBean = (UserLoginSessionBeanRemote) context.lookup("ejb/stateless-login"); //NOI18N
} catch (final NamingException ex) {
// Continue to throw
throw new FaceletException(ex);
try {
// Call bean
- this.login.loginUser(user);
+ this.loginBean.loginUser(user);
} catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException ex) {
// Throw again
throw new FaceletException(ex);
import org.mxchange.jusercore.exceptions.UserAlreadyRegisteredException;
import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
/**
* A web bean for user registration
/**
* Reemote register session bean
*/
- private UserRegistrationSessionBeanRemote register;
+ private UserRegistrationSessionBeanRemote registerBean;
/**
* User controller
Context context = new InitialContext();
// Try to lookup
- this.register = (UserRegistrationSessionBeanRemote) context.lookup("ejb/stateless-register"); //NOI18N
+ this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("ejb/stateless-register"); //NOI18N
} catch (final NamingException ex) {
// Continue to throw
throw new FaceletException(ex);
}
@Override
- public void doRegister () {
+ public String doRegister () {
// Get user instance
User user = this.userController.createUserInstance();
+ // For debugging/programming only:
+ user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
+
try {
// Call bean
- this.register.registerUser(user);
+ User registeredUser = this.registerBean.registerUser(user);
+
+ // Copy all data from registered->user
+ this.userController.copyUser(registeredUser);
+
+ // All fine, redirect to proper page
+ return "register_done"; //NOI18N
} catch (final UserAlreadyRegisteredException ex) {
// Continue to throw
throw new FaceletException(ex);
/**
* Registers the user, if not found. Otherwise this method should throw an
* exception.
+ * <p>
+ * @return Redirection target
*/
- public void doRegister ();
+ public String doRegister ();
}
*/
package org.mxchange.addressbook.beans.user;
+import java.util.Date;
import javax.enterprise.context.SessionScoped;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Named;
private static final long serialVersionUID = 542_145_347_916L;
/////////////////////// Properties /////////////////////
+
+ /**
+ * Birth day
+ */
+ private Date birthday;
+
/**
* Cellphone number
*/
*/
private String comment;
- /**
- * Company name
- */
- private String companyName;
-
/**
* Country code
*/
*/
private Short houseNumber;
+ /**
+ * User id
+ */
+ private Long userId;
+
/**
* Phone number
*/
}
}
+ @Override
+ public void copyUser (final User user) {
+ // Copy all fields:
+ // - base data
+ this.setUserId(user.getUserId());
+ this.setGender(user.getUserContact().getGender());
+ this.setFirstName(user.getUserContact().getFirstName());
+ this.setFamilyName(user.getUserContact().getFamilyName());
+ this.setStreet(user.getUserContact().getStreet());
+ this.setHouseNumber(user.getUserContact().getHouseNumber());
+ this.setZipCode(user.getUserContact().getZipCode());
+ this.setCity(user.getUserContact().getCity());
+ this.setCountryCode(user.getUserContact().getCountryCode());
+
+ // - contact data
+ this.setPhoneNumber(user.getUserContact().getPhoneNumber());
+ this.setCellphoneNumber(user.getUserContact().getCellphoneNumber());
+ this.setFaxNumber(user.getUserContact().getFaxNumber());
+ this.setEmailAddress(user.getUserContact().getEmailAddress());
+
+ // -- other data
+ this.setBirthday(user.getUserContact().getBirthday());
+ this.setComment(user.getUserContact().getComment());
+ }
+
@Override
public User createUserInstance () {
// User message
user.setUserName(this.getUserName());
// Create new contact
- Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName(), this.getCompanyName());
+ Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
contact.setStreet(this.getStreet());
contact.setHouseNumber(this.getHouseNumber());
contact.setZipCode(this.getZipCode());
contact.setPhoneNumber(this.getPhoneNumber());
contact.setFaxNumber(this.getFaxNumber());
contact.setCellphoneNumber(this.getCellphoneNumber());
+ contact.setBirthday(this.getBirthday());
contact.setComment(this.getComment());
// Set contact in user
return user;
}
+ @Override
+ public Date getBirthday () {
+ return birthday;
+ }
+
+ @Override
+ public void setBirthday (final Date birthday) {
+ this.birthday = birthday;
+ }
+
@Override
public String getCellphoneNumber () {
return this.cellphoneNumber;
this.comment = comment;
}
- @Override
- public String getCompanyName () {
- return this.companyName;
- }
-
- @Override
- public void setCompanyName (final String companyName) {
- this.companyName = companyName;
- }
-
@Override
public String getCountryCode () {
return this.countryCode;
this.street = street;
}
+ @Override
+ public Long getUserId () {
+ return this.userId;
+ }
+
+ @Override
+ public void setUserId (final Long userId) {
+ this.userId = userId;
+ }
+
@Override
public String getUserName () {
return this.userName;
package org.mxchange.addressbook.beans.user;
import java.io.Serializable;
+import java.util.Date;
import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jusercore.model.user.User;
*/
public interface UserWebController extends Serializable {
+ /**
+ * Copies given user into the controller
+ * <p>
+ * @param user User instance
+ */
+ public void copyUser (final User user);
+
/**
* Creates an instance from all properties
* <p>
*/
public User createUserInstance ();
+ /**
+ * Getter for birth day
+ * <p>
+ * @return Birth day
+ */
+ public Date getBirthday ();
+
+ /**
+ * Setter for birth day
+ * <p>
+ * @param birthday Birth day
+ */
+ public void setBirthday (final Date birthday);
+
/**
* Cellphone number
* <p>
*/
public void setComment (final String comment);
+ /**
+ * Getter for user id
+ * <p>
+ * @return User id
+ */
+ public Long getUserId ();
+
+ /**
+ * Setter for user id
+ * <p>
+ * @param userId User id
+ */
+ public void setUserId (final Long userId);
+
/**
* Getter for user name
* <p>
*/
public void setUserPassword (final String userPassword);
- /**
- * Company name
- * <p>
- * @return the companyName
- */
- public String getCompanyName ();
-
- /**
- * Company name
- * <p>
- * @param companyName the companyName to set
- */
- public void setCompanyName (final String companyName);
-
/**
* Country code
* <p>
TERMS_NOT_ACCEPTED_MESSAGE=Bitte den AGBs zustimmen.
PERSONAL_DATA_MINIMUM_NOTICE=Bitte geben Sie mindestens Name, Anschrift und Telefonnummer an.
PERSONAL_DATA_GENDER=Anrede:
-PERSONAL_DATA_COMPANY_NAME=Firmenname:
PERSONAL_DATA_FIRST_NAME=Vorname:
PERSONAL_DATA_FAMILY_NAME=Nachname:
PERSONAL_DATA_STREET=Stra\u00dfe:
BUTTON_CONTINUE_STEP_2=Weiter zu Schritt 2
GUEST_REGISTRATION_ENTER_USER_NAME=Benutzernamen eingeben:
GUEST_REGISTRATION_USER_NAME_NOTICE=Der Benutzername darf nur einmal vorkommen.
+LINK_GUEST_RESENT_CONFIRMATION_LINK=Nochmals den Best\u00e4tigungslink aussenden?
+GUEST_REGISTRATION_COMPLETED=Die Anmeldung ist abgeschlossen und Ihr Account wartet auf Freischaltung. Es ist eine Email mit einem entsprechenden Best\u00e4tigungslink zu Ihnen unterwegs. Diesen m\u00fcssen Sie einmal anklicken oder in die Adresszeile des Browsers kopieren und dann aufrufen lassen. Danach ist Ihr Account freigegeben.
TERMS_NOT_ACCEPTED_MESSAGE=Please accept Terms&Conditions.
PERSONAL_DATA_MINIMUM_NOTICE=Please enter at least your name, address and phone number.
PERSONAL_DATA_GENDER=Salutation:
-PERSONAL_DATA_COMPANY_NAME=Company name:
PERSONAL_DATA_FIRST_NAME=First name:
PERSONAL_DATA_FAMILY_NAME=Family name:
PERSONAL_DATA_STREET=Street:
BUTTON_CONTINUE_STEP_2=Weiter zu Schritt 2
GUEST_REGISTRATION_ENTER_USER_NAME=Enter user name:
GUEST_REGISTRATION_USER_NAME_NOTICE=The user name must only exist once.
+LINK_GUEST_RESENT_CONFIRMATION_LINK=Resend again the confirmation link?
+GUEST_REGISTRATION_COMPLETED=The registration is completed and your account is pending confirmation. An email has been sent to you. There you will find a confirmation link which you have to click once or copy it into your browser's address bar and call it.
</validator>
<navigation-rule>
<from-view-id>*</from-view-id>
- <navigation-case>
- <from-outcome>user_register</from-outcome>
- <to-view-id>/user/register.xhtml</to-view-id>
- </navigation-case>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>user_lost_passwd</from-outcome>
- <to-view-id>/user/lost_passwd.xhtml</to-view-id>
+ <from-outcome>user_register</from-outcome>
+ <to-view-id>/user/register.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>user_login</from-outcome>
<to-view-id>/user/login.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>user_lost_passwd</from-outcome>
+ <to-view-id>/user/lost_passwd.xhtml</to-view-id>
+ </navigation-case>
<navigation-case>
<from-outcome>terms</from-outcome>
<to-view-id>/terms.xhtml</to-view-id>
<from-outcome>logout</from-outcome>
<to-view-id>/bye.xhtml</to-view-id>
</navigation-case>
- <navigation-case>
- <from-outcome>admin_product</from-outcome>
- <to-view-id>/admin/product.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>admin_category</from-outcome>
- <to-view-id>/admin/category.xhtml</to-view-id>
- </navigation-case>
<navigation-case>
<from-outcome>admin_index</from-outcome>
<to-view-id>/admin/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
+ <navigation-rule>
+ <from-view-id>/user/register.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>register_done</from-outcome>
+ <to-view-id>/user/register_done.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
<navigation-rule>
<from-view-id>/admin/admin_logout.xhtml</from-view-id>
<navigation-case>
<div class="clear"></div>
</div>
- <div class="table_row">
- <div class="table_left">
- <h:outputLabel for="companyname" value="#{msg.PERSONAL_DATA_COMPANY_NAME}" />
- </div>
-
- <div class="table_right">
- <h:inputText class="input" id="companyname" size="15" maxlength="255" value="#{userController.companyName}" />
- </div>
-
- <div class="clear"></div>
- </div>
-
<div class="table_row">
<div class="table_left">
<h:outputLabel for="firstName" value="#{msg.PERSONAL_DATA_FIRST_NAME}" />
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
- <display-name>Addressbook Application v1.0</display-name>
- <context-param>
- <param-name>javax.faces.PROJECT_STAGE</param-name>
- <param-value>Development</param-value>
- </context-param>
- <servlet>
- <servlet-name>Faces Servlet</servlet-name>
- <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces/*</url-pattern>
- </servlet-mapping>
- <session-config>
- <session-timeout>
+ <display-name>Addressbook Application v1.0</display-name>
+ <context-param>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>
30
</session-timeout>
- </session-config>
- <welcome-file-list>
- <welcome-file>faces/index.xhtml</welcome-file>
- </welcome-file-list>
- <security-constraint>
- <display-name>Constraint1</display-name>
- <web-resource-collection>
- <web-resource-name>loginArea</web-resource-name>
- <description>Login area</description>
- <url-pattern>/llogin/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <description>User Authentication</description>
- <role-name>user</role-name>
- </auth-constraint>
- </security-constraint>
- <login-config>
- <auth-method>FORM</auth-method>
- <realm-name>Loginbereich / Login area</realm-name>
- <form-login-config>
- <form-login-page>/user/login.xhtml</form-login-page>
- <form-error-page>/user/login_error.xhtml</form-error-page>
- </form-login-config>
- </login-config>
- <security-role>
- <description>A logged-in user that has previously registered himself/herself.</description>
- <role-name>user</role-name>
- </security-role>
- <mime-mapping>
- <extension>tpl</extension>
- <mime-type>text/plain</mime-type>
- </mime-mapping>
+ </session-config>
+ <welcome-file-list>
+ <welcome-file>faces/index.xhtml</welcome-file>
+ </welcome-file-list>
+ <security-constraint>
+ <display-name>LoginConstraint</display-name>
+ <web-resource-collection>
+ <web-resource-name>loginArea</web-resource-name>
+ <description>Login area</description>
+ <url-pattern>/llogin/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <description>User Authentication</description>
+ <role-name>user</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <security-constraint>
+ <display-name>AdminConstraint</display-name>
+ <web-resource-collection>
+ <web-resource-name>admin</web-resource-name>
+ <description>Administrative area</description>
+ <url-pattern>/admin/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <description>Admin authentication</description>
+ <role-name>admin</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <realm-name>Loginbereich / Login area</realm-name>
+ <form-login-config>
+ <form-login-page>/user/login.xhtml</form-login-page>
+ <form-error-page>/user/login_error.xhtml</form-error-page>
+ </form-login-config>
+ </login-config>
+ <security-role>
+ <description>A logged-in user that has previously registered himself/herself.</description>
+ <role-name>user</role-name>
+ </security-role>
+ <mime-mapping>
+ <extension>tpl</extension>
+ <mime-type>text/plain</mime-type>
+ </mime-mapping>
+ <security-role>
+ <description>Administrativre rule</description>
+ <role-name>admin</role-name>
+ </security-role>
</web-app>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <ui:composition template="/WEB-INF/templates/guest/guest_base.tpl">
+ <ui:define name="title">#{msg.PAGE_TITLE_USER_REGISTER_DONE}</ui:define>
+
+ <ui:define name="menu">
+ <ui:include id="menu" class="guest_menu" src="/WEB-INF/templates/guest/guest_menu.tpl" />
+ </ui:define>
+
+ <ui:define name="content_header">
+ #{msg.SUB_TITLE_USER_REGISTER_DONE}
+ </ui:define>
+
+ <ui:define name="content">
+ <div class="para">
+ #{msg.GUEST_USER_REGISTRATION_COMPLETED}
+ </div>
+
+ <div class="registration_form">
+ <h:link id="resend_link" class="resend_link" value="#{msg.LINK_GUEST_RESENT_CONFIRMATION_LINK}" outcome="resend_link">
+ <f:param name="user_id" value="#{userController.userId}" />
+ </h:link>
+ </div>
+ </ui:define>
+
+ <ui:define name="footer">
+ <ui:include id="footer" class="guest_footer" src="/WEB-INF/templates/guest/guest_footer.tpl" />
+ </ui:define>
+ </ui:composition>
+</html>