From e3e16631dafe1f66f9225208dd375e4c1e365818 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 20 May 2016 17:36:54 +0200 Subject: [PATCH] Continued a bit: - first @Oberserves, then final - added simple birthday input field - added i18n strings - added birthday to export as well - added observer method afterUserConfirmedAccount() to update lists for - added javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE to make sure time-zone problems are fixed - fixed some messages, wrong stuff there MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- nbproject/faces-config.NavData | 146 +++++++++--------- .../localization/bundle_de_DE.properties | 2 + .../localization/bundle_en_US.properties | 2 + .../contact/PizzaContactWebSessionBean.java | 56 ++++++- .../PizzaContactWebSessionController.java | 8 + .../user/PizzaAdminUserWebRequestBean.java | 2 +- .../beans/user/PizzaUserWebSessionBean.java | 43 +++++- .../user/PizzaUserWebSessionController.java | 8 + .../templates/contact/form_contact_data.tpl | 19 ++- web/WEB-INF/web.xml | 4 + web/admin/contact/admin_contact_export.xhtml | 12 +- 11 files changed, 219 insertions(+), 83 deletions(-) diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 2d20ca61..d01e4f20 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -2,81 +2,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 9b7a938b..a9b55ee0 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -523,3 +523,5 @@ ADMIN_EXPORT_CONTACTS_TIMEOUT_WARNING=Bei sehr gro\u00dfen Datenmengen kann es e BUTTON_ADMIN_EXPORT_CONTACTS_CSV=Alle Daten als CSV-Datei exportieren LINK_ADMIN_EXPORT_CONTACT=Daten exportieren LINK_ADMIN_EXPORT_CONTACT_TITLE=Kontaktdaten exportieren +PERSONAL_DATA_BIRTHDAY=Geburtsdatum (dd.mm.jjjj): +BIRTHDAY_PATTERN=dd.MM.yyyy diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 5bb27e62..c458fadf 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -508,3 +508,5 @@ ADMIN_EXPORT_CONTACTS_TIMEOUT_WARNING=Big data amount may lead to timeouts. You BUTTON_ADMIN_EXPORT_CONTACTS_CSV=Export all data as CSV file LINK_ADMIN_EXPORT_CONTACT=Export data LINK_ADMIN_EXPORT_CONTACT_TITLE=Export contact data +PERSONAL_DATA_BIRTHDAY=Birthday (mm-dd-yyyy): +BIRTHDAY_PATTERN=MM-dd-yyyy diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java index b1a7c55b..3ed20d67 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java @@ -48,6 +48,7 @@ import org.mxchange.jphone.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; +import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -308,10 +309,10 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P throw new NullPointerException("event is null"); //NOI18N } else if (event.getUpdatedContact() == null) { // Throw NPE again - throw new NullPointerException("event.updatedUser is null"); //NOI18N + throw new NullPointerException("event.updatedContact is null"); //NOI18N } else if (event.getUpdatedContact().getContactId() == null) { // userId is null - throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N } else if (event.getUpdatedContact().getContactId() < 1) { // Not avalid id throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N @@ -354,10 +355,10 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P throw new NullPointerException("event is null"); //NOI18N } else if (event.getRegisteredUser() == null) { // Throw NPE again - throw new NullPointerException("event.user is null"); //NOI18N + throw new NullPointerException("event.registeredUser is null"); //NOI18N } else if (event.getRegisteredUser().getUserId() == null) { // userId is null - throw new NullPointerException("event.user.userId is null"); //NOI18N + throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N } else if (event.getRegisteredUser().getUserId() < 1) { // Not avalid id throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N @@ -382,6 +383,49 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N } + @Override + public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) { + // Trace message + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N + + // event should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getConfirmedUser() == null) { + // Throw NPE again + throw new NullPointerException("event.confirmedUser is null"); //NOI18N + } else if (event.getConfirmedUser().getUserId() == null) { + // userId is null + throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N + } else if (event.getConfirmedUser().getUserId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N + } + + // "Cache" contact instance + Contact contact = event.getConfirmedUser().getUserContact(); + + // Get iterator from list + Iterator iterator = this.contactList.iterator(); + + // "Walk" through all entries + while (iterator.hasNext()) { + // Get next element + Contact next = iterator.next(); + + // Is id number the same? + if (Objects.equals(contact.getContactId(), next.getContactId())) { + // Found entry, so remove it and abort + this.contactList.remove(next); + break; + } + } + + // Add contact to list + this.contactList.add(contact); + } + @Override public void afterUserLogin (@Observes final UserLoggedInEvent event) { // Trace message @@ -393,10 +437,10 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P throw new NullPointerException("event is null"); //NOI18N } else if (event.getLoggedInUser() == null) { // Throw NPE again - throw new NullPointerException("event.user is null"); //NOI18N + throw new NullPointerException("event.loggedInUser is null"); //NOI18N } else if (event.getLoggedInUser().getUserId() == null) { // userId is null - throw new NullPointerException("event.user.userId is null"); //NOI18N + throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N } else if (event.getLoggedInUser().getUserId() < 1) { // Not avalid id throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java index 71ad1741..6b4f000b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java @@ -27,6 +27,7 @@ import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcountry.data.Country; import org.mxchange.jcustomercore.events.customer.added.AdminAddedCustomerEvent; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; +import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -64,6 +65,13 @@ public interface PizzaContactWebSessionController extends Serializable { */ void afterAdminAddedUserEvent (final AdminAddedUserEvent event); + /** + * Event observer when user confirmed account. + *

+ * @param event Event being fired + */ + void afterUserConfirmedAccount (final UserConfirmedAccountEvent event); + /** * Updates all data from bean in given contact instance *

diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java index 5eb50833..6aaa25a2 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java @@ -262,7 +262,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements } @Override - public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) { + public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) { // Trace message //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminUserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java index d986447e..8ec13932 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java @@ -36,6 +36,7 @@ import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; +import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -312,7 +313,47 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz } @Override - public void afterUserLogin (final @Observes UserLoggedInEvent event) { + public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) { + // Trace message + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N + + // event should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getConfirmedUser() == null) { + // Throw NPE again + throw new NullPointerException("event.confirmedUser is null"); //NOI18N + } else if (event.getConfirmedUser().getUserId() == null) { + // userId is null + throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N + } else if (event.getConfirmedUser().getUserId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N + } + + // Get iterator from list + Iterator iterator = this.userList.iterator(); + + // "Walk" through all entries + while (iterator.hasNext()) { + // Get next element + User next = iterator.next(); + + // Is id number the same? + if (Objects.equals(event.getConfirmedUser().getUserId(), next.getUserId())) { + // Found entry, so remove it and abort + this.userList.remove(next); + break; + } + } + + // Add contact to list + this.userList.add(event.getConfirmedUser()); + } + + @Override + public void afterUserLogin (@Observes final UserLoggedInEvent event) { // Trace message //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java index bb2d8ef3..63cbf2f4 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java @@ -20,6 +20,7 @@ import java.io.Serializable; import java.util.List; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; +import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -64,6 +65,13 @@ public interface PizzaUserWebSessionController extends Serializable { */ void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event); + /** + * Event observer when user confirmed account. + *

+ * @param event Event being fired + */ + void afterUserConfirmedAccount (final UserConfirmedAccountEvent event); + /** * Listens to fired event when user updated personal data *

diff --git a/web/WEB-INF/templates/contact/form_contact_data.tpl b/web/WEB-INF/templates/contact/form_contact_data.tpl index 55d2234c..1e826c36 100644 --- a/web/WEB-INF/templates/contact/form_contact_data.tpl +++ b/web/WEB-INF/templates/contact/form_contact_data.tpl @@ -3,7 +3,8 @@ xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" - xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:p="http://primefaces.org/ui">

#{msg.PERSONAL_DATA_MINIMUM_NOTICE} @@ -111,6 +112,22 @@
+
+
+ +
+ +
+ + + +
+ +
+
+ + +
diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index f5133bf9..710ed1c1 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -27,6 +27,10 @@ is_resend_confirm_link_enabled true + + javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE + true + Faces Servlet javax.faces.webapp.FacesServlet diff --git a/web/admin/contact/admin_contact_export.xhtml b/web/admin/contact/admin_contact_export.xhtml index 91b6c58c..af009469 100644 --- a/web/admin/contact/admin_contact_export.xhtml +++ b/web/admin/contact/admin_contact_export.xhtml @@ -109,6 +109,16 @@ + + + + + + + + + + @@ -139,7 +149,7 @@ - + -- 2.39.5