From 233958b698ba6dd4412b991f6fb75f9ed7611adb 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 | 122 +++++++++--------- .../contact/JobsContactWebSessionBean.java | 56 +++++++- .../JobsContactWebSessionController.java | 8 ++ .../beans/user/JobsUserWebSessionBean.java | 41 ++++++ .../user/JobsUserWebSessionController.java | 8 ++ .../localization/bundle_de_DE.properties | 2 + .../localization/bundle_en_US.properties | 2 + .../templates/contact/form_contact_data.tpl | 19 ++- web/WEB-INF/web.xml | 4 + web/admin/contact/admin_contact_export.xhtml | 12 +- 10 files changed, 205 insertions(+), 69 deletions(-) diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 0da39fd7..ddb627aa 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -2,67 +2,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index 7f86bc6c..26c1c493 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -49,6 +49,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; @@ -283,10 +284,10 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job 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 @@ -329,10 +330,10 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job 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 @@ -357,6 +358,49 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job //* 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 @@ -368,10 +412,10 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job 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/jjobs/beans/contact/JobsContactWebSessionController.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java index dd508b54..4a321500 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java @@ -26,6 +26,7 @@ import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcountry.data.Country; 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; @@ -63,6 +64,13 @@ public interface JobsContactWebSessionController 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/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index de3bba0a..afeadabd 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -40,6 +40,7 @@ import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController; import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController; import org.mxchange.jjobs.beans.register.JobsUserRegisterWebSessionController; +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; @@ -304,6 +305,46 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs //* NOISY-DEBUG: */ System.out.println("UserWebBean: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 + } + + // 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 diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java index 623e3fa3..ba624983 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.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 JobsUserWebSessionController 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/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 78e601d2..1bcc1676 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -517,3 +517,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 c075cd77..f796d54d 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -518,3 +518,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/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 3d511878..aa65497c 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