From: Roland Haeder Date: Sat, 5 Mar 2016 21:02:24 +0000 (+0100) Subject: Continued with "change personal data": X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e705d5493eb5b4ef4bf3ee555bd86e3dac2098a4;p=jjobs-war.git Continued with "change personal data": - updating the user instance didn't work the previous way, first you need to copy the loginController.loggedInUser instance and then you can update all fields on it - added generic template message_box.tpl - added generic page login_data_saved.xhtml - added missing navigation rules from login_change_foo.xhtml -> login_data_saved.xhtml - added some new language strings - added CSS classes for message box template - changing email address requires you to enter twice your new email address (displaying old is missing) --- diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 9a3038d3..5ab655d9 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -2,32 +2,33 @@ - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java index 434cf74e..e2919895 100644 --- a/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java @@ -255,14 +255,51 @@ public class UserWebSessionBean implements UserWebSessionController { // Get user instance User user = this.loginController.getLoggedInUser(); + // It should be there, so run some tests on it + assert (user instanceof User) : "Instance loginController.loggedInUser is null"; + assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; + assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); + assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; + assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; + assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); + // Update all fields - this.updateUserFromFields(user); + user.setUserProfileMode(this.getUserProfileMode()); + user.getUserContact().setContactGender(this.getGender()); + user.getUserContact().setContactFirstName(this.getFirstName()); + user.getUserContact().setContactFamilyName(this.getFamilyName()); + user.getUserContact().setContactStreet(this.getStreet()); + user.getUserContact().setContactHouseNumber(this.getHouseNumber()); + user.getUserContact().setContactZipCode(this.getZipCode()); + user.getUserContact().setContactCity(this.getCity()); + user.getUserContact().setContactCountry(this.getCountry()); + + // Is there a phone number? + if (user.getUserContact().getContactPhoneNumber() instanceof DialableLandLineNumber) { + // Yes, then update as well + user.getUserContact().getContactPhoneNumber().setPhoneAreaCode(this.getPhoneAreaCode()); + user.getUserContact().getContactPhoneNumber().setPhoneNumber(this.getPhoneNumber()); + } + + // Is there a fax number? + if (user.getUserContact().getContactFaxNumber() instanceof DialableFaxNumber) { + // Yes, then update as well + user.getUserContact().getContactFaxNumber().setPhoneAreaCode(this.getFaxAreaCode()); + user.getUserContact().getContactFaxNumber().setPhoneNumber(this.getFaxNumber()); + } + + // Is there a cellphone number? + if (user.getUserContact().getContactCellphoneNumber() instanceof DialableCellphoneNumber) { + // Yes, then update as well + user.getUserContact().getContactCellphoneNumber().setCellphoneProvider(this.getCellphoneCarrier()); + user.getUserContact().getContactCellphoneNumber().setPhoneNumber(this.getCellphoneNumber()); + } // Send it to the EJB this.userBean.updateUserPersonalData(user); // All fine - return "login_personal_data_changed"; //NOI18N + return "login_data_saved"; //NOI18N } @Override @@ -349,17 +386,16 @@ public class UserWebSessionBean implements UserWebSessionController { return Collections.unmodifiableList(this.visibleUserList); } - /** - * Updates given user instance with all (updated) data from this controller - *

- * @param user User instance to to be updated - */ - private void updateUserFromFields (final User user) { - // Make sure it is valid - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } + @Override + public User createUserInstance () { + // User message + //this.getLogger().logTrace("createUserInstance: CALLED!"); + + // Required personal data must be set + assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N + + // Create new user instance + User user = new LoginUser(); // Update all data ... user.setUserName(this.getUserName()); @@ -446,25 +482,9 @@ public class UserWebSessionBean implements UserWebSessionController { // Set contact in user user.setUserContact(contact); - } - - @Override - public User createUserInstance () { - // User message - //this.getLogger().logTrace("createUserInstance: CALLED!"); - - // Required personal data must be set - assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N - - // Create new user instance - User user = new LoginUser(); - - // Update all fields - this.updateUserFromFields(user); // Trace message //this.getLogger().logTrace(MessageFormat.format("createUserInstance: user={0} - EXIT!", user)); - // Return it return user; } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 9c3dca0a..1af074c8 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -257,3 +257,8 @@ BUTTON_CHANGE_PERSONAL_DATA=Persoenliche Daten aendern #TODO: Please fix German umlaut! LOGIN_CHANGE_PERSONAL_DATA_TITLE=Persoenliche Daten aendern: ERROR_CURRENT_PASSWORD_MISMATCHING=Ihr eingegebenes Passwort entspricht nicht dem aktuell gespeicherten Passwort. +MESSAGE_BOX_TITLE=Hinweis: +MESSAGE_BOX_PARAMETER_MESSAGE_EMPTY=Fehler: Parameter "message" nicht gesetzt. +LOGIN_MESSAGE_DATA_SAVED=Daten wurden gespeichert. +PAGE_TITLE_LOGIN_DATA_SAVED=Ihre Daten wurden gespeichert +CONTENT_TITLE_LOGIN_DATA_SAVED=Daten wurden gespeichert: diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index a348ece0..04be3fc4 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -241,3 +241,8 @@ LOGIN_ENTER_CURRENT_PASSWORD_CONFIRM=Current password: BUTTON_CHANGE_PERSONAL_DATA=Change personal data LOGIN_CHANGE_PERSONAL_DATA_TITLE=Change personal data: ERROR_CURRENT_PASSWORD_MISMATCHING=Your entered password doesn't match the currently stored one. +MESSAGE_BOX_TITLE=Notice: +MESSAGE_BOX_PARAMETER_MESSAGE_EMPTY=Error: Parameter "message" not set. +LOGIN_MESSAGE_DATA_SAVED=Data has been saved. +PAGE_TITLE_LOGIN_DATA_SAVED=Your data has been saved +CONTENT_TITLE_LOGIN_DATA_SAVED=Data has been saved: diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 25547658..6ecb56af 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -159,4 +159,25 @@ /login/login_change_personal_data.xhtml + + /login/login_change_password.xhtml + + login_data_saved + /login/login_data_saved.xhtml + + + + /login/login_change_email_address.xhtml + + login_data_saved + /login/login_data_saved.xhtml + + + + /login/login_change_personal_data.xhtml + + login_data_saved + /login/login_data_saved.xhtml + + diff --git a/web/WEB-INF/templates/generic/message_box.tpl b/web/WEB-INF/templates/generic/message_box.tpl new file mode 100644 index 00000000..4b8ecb64 --- /dev/null +++ b/web/WEB-INF/templates/generic/message_box.tpl @@ -0,0 +1,26 @@ + + + + +

+
+ #{msg.MESSAGE_BOX_TITLE} +
+ + +
+ #{message} +
+
+ + +
+ #{msg.MESSAGE_BOX_PARAMETER_MESSAGE_EMPTY} +
+
+
+ diff --git a/web/login/login_change_email_address.xhtml b/web/login/login_change_email_address.xhtml index 1dbb0f27..7550822b 100644 --- a/web/login/login_change_email_address.xhtml +++ b/web/login/login_change_email_address.xhtml @@ -31,7 +31,7 @@
- +
@@ -43,7 +43,7 @@
- +
diff --git a/web/login/login_data_saved.xhtml b/web/login/login_data_saved.xhtml new file mode 100644 index 00000000..d4fa96b4 --- /dev/null +++ b/web/login/login_data_saved.xhtml @@ -0,0 +1,28 @@ + + + + + + #{msg.PAGE_TITLE_LOGIN_DATA_SAVED} + + + #{msg.CONTENT_TITLE_LOGIN_DATA_SAVED} + + + + + + + + + + + + + + diff --git a/web/resources/css/cssLayout.css b/web/resources/css/cssLayout.css index eb81f7e8..456d1d2c 100644 --- a/web/resources/css/cssLayout.css +++ b/web/resources/css/cssLayout.css @@ -129,7 +129,7 @@ ul.footer_nav li.footer_copyright { padding-left: 5px; } -.table_header, .table_label { +.table_header, .table_label, .message_header { text-align: center; font-weight: bold; } @@ -173,3 +173,15 @@ ul.footer_nav li.footer_copyright { .warnings { color: gold; } + +.message_box { + width: 400px; +} + +.message_header { + background-color: #036fab; +} + +.okay { + color: #00aa00; +}