]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with "change personal data":
authorRoland Haeder <roland@mxchange.org>
Sat, 5 Mar 2016 21:02:24 +0000 (22:02 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 5 Mar 2016 21:04:10 +0000 (22:04 +0100)
- 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)

nbproject/faces-config.NavData
src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/generic/message_box.tpl [new file with mode: 0644]
web/login/login_change_email_address.xhtml
web/login/login_data_saved.xhtml [new file with mode: 0644]
web/resources/css/cssLayout.css

index 9a3038d34e4a84753789d4a5179074b68ab18f21..5ab655d9a7382348c8d4bf51d88e3a6849095bae 100644 (file)
@@ -2,32 +2,33 @@
 <Scene Scope="Project" version="2">
     <Scope Scope="Faces Configuration Only"/>
     <Scope Scope="Project">
-        <Node id="privacy.xhtml" x="900" y="450" zoom="true"/>
-        <Node id="login/login_change_password.xhtml" x="1400" y="150" zoom="true"/>
-        <Node id="user/register.xhtml" x="400" y="600" zoom="true"/>
-        <Node id="login/login_all_applications.xhtml" x="650" y="150" zoom="true"/>
-        <Node id="login/login_index.xhtml" x="650" y="300" zoom="true"/>
-        <Node id="user/resend_link.xhtml" x="150" y="750" zoom="true"/>
-        <Node id="login/login_add_addressbook.xhtml" x="900" y="600" zoom="true"/>
-        <Node id="login/login_own_addressbooks.xhtml" x="1650" y="150" zoom="true"/>
-        <Node id="admin/admin_logout.xhtml" x="400" y="750" zoom="true"/>
+        <Node id="login/login_change_password.xhtml" x="900" y="450" zoom="true"/>
+        <Node id="privacy.xhtml" x="150" y="900" zoom="true"/>
+        <Node id="login/login_data_saved.xhtml" x="400" y="300" zoom="true"/>
+        <Node id="user/register.xhtml" x="1150" y="150" zoom="true"/>
+        <Node id="login/login_all_applications.xhtml" x="650" y="750" zoom="true"/>
+        <Node id="login/login_add_addressbook.xhtml" x="150" y="600" zoom="true"/>
+        <Node id="user/resend_link.xhtml" x="650" y="600" zoom="true"/>
+        <Node id="login/login_index.xhtml" x="900" y="600" zoom="true"/>
+        <Node id="login/login_own_addressbooks.xhtml" x="1150" y="300" zoom="true"/>
         <Node id="terms.xhtml" x="150" y="150" zoom="true"/>
-        <Node id="user/user_list.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="bye.xhtml" x="650" y="750" zoom="true"/>
-        <Node id="index.xhtml" x="400" y="450" zoom="true"/>
-        <Node id="user/register_done.xhtml" x="1400" y="300" zoom="true"/>
-        <Node id="user/user_profile.xhtml" x="1150" y="450" zoom="true"/>
-        <Node id="login/login_change_personal_data.xhtml" x="150" y="300" zoom="true"/>
-        <Node id="user/show_addressbook.xhtml" x="650" y="600" zoom="true"/>
-        <Node id="imprint.xhtml" x="1150" y="300" zoom="true"/>
-        <Node id="*" x="150" y="900" zoom="true"/>
-        <Node id="user/login_error.xhtml" x="1150" y="150" zoom="true"/>
-        <Node id="user/show_addressbook_entries.xhtml" x="400" y="900" zoom="true"/>
-        <Node id="admin/admin_index.xhtml" x="150" y="450" zoom="true"/>
-        <Node id="login/login_change_email_address.xhtml" x="400" y="150" zoom="true"/>
-        <Node id="user/lost_passwd.xhtml" x="650" y="450" zoom="true"/>
-        <Node id="user/login.xhtml" x="150" y="600" zoom="true"/>
-        <Node id="login/login_edit_user_data.xhtml" x="400" y="300" zoom="true"/>
+        <Node id="admin/admin_logout.xhtml" x="400" y="900" zoom="true"/>
+        <Node id="user/user_list.xhtml" x="150" y="450" zoom="true"/>
+        <Node id="bye.xhtml" x="650" y="150" zoom="true"/>
+        <Node id="index.xhtml" x="650" y="300" zoom="true"/>
+        <Node id="user/register_done.xhtml" x="400" y="450" zoom="true"/>
+        <Node id="user/user_profile.xhtml" x="900" y="150" zoom="true"/>
+        <Node id="login/login_change_personal_data.xhtml" x="650" y="450" zoom="true"/>
+        <Node id="*" x="150" y="300" zoom="true"/>
+        <Node id="imprint.xhtml" x="400" y="600" zoom="true"/>
+        <Node id="user/show_addressbook.xhtml" x="150" y="750" zoom="true"/>
+        <Node id="user/login_error.xhtml" x="900" y="300" zoom="true"/>
+        <Node id="user/show_addressbook_entries.xhtml" x="1650" y="150" zoom="true"/>
+        <Node id="admin/admin_index.xhtml" x="1400" y="150" zoom="true"/>
+        <Node id="login/login_change_email_address.xhtml" x="1150" y="450" zoom="true"/>
+        <Node id="user/lost_passwd.xhtml" x="400" y="750" zoom="true"/>
+        <Node id="user/login.xhtml" x="400" y="150" zoom="true"/>
+        <Node id="login/login_edit_user_data.xhtml" x="1400" y="300" zoom="true"/>
     </Scope>
     <Scope Scope="All Faces Configurations"/>
 </Scene>
index 434cf74e458655873a26463b895a2dadd2a88366..e2919895f19bfaa2979804dfa818645fcaff9774 100644 (file)
@@ -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
-        * <p>
-        * @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;
        }
index 9c3dca0a1e5eaee34ce459058aaeb5c4884d2954..1af074c8736ffb10eb4c99861f9220dfdc47c44e 100644 (file)
@@ -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:
index a348ece0e224ff7c4bc3dbc747360029a7db4dae..04be3fc4fb215b0523c0d247f5b8446684ac9cc4 100644 (file)
@@ -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:
index 25547658f8cdd4241ae62d024e7b61ffc7b06118..6ecb56af6f8e34800e36fabbfbc528ce25d1f544 100644 (file)
                        <to-view-id>/login/login_change_personal_data.xhtml</to-view-id>
                </navigation-case>
        </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/login/login_change_password.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>login_data_saved</from-outcome>
+                       <to-view-id>/login/login_data_saved.xhtml</to-view-id>
+               </navigation-case>
+       </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/login/login_change_email_address.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>login_data_saved</from-outcome>
+                       <to-view-id>/login/login_data_saved.xhtml</to-view-id>
+               </navigation-case>
+       </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/login/login_change_personal_data.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>login_data_saved</from-outcome>
+                       <to-view-id>/login/login_data_saved.xhtml</to-view-id>
+               </navigation-case>
+       </navigation-rule>
 </faces-config>
diff --git a/web/WEB-INF/templates/generic/message_box.tpl b/web/WEB-INF/templates/generic/message_box.tpl
new file mode 100644 (file)
index 0000000..4b8ecb6
--- /dev/null
@@ -0,0 +1,26 @@
+<?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:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <div class="message_box">
+               <div class="message_header">
+                       #{msg.MESSAGE_BOX_TITLE}
+               </div>
+
+               <ui:fragment id="output_message" rendered="#{not empty message}">
+                       <div class="okay para">
+                               #{message}
+                       </div>
+               </ui:fragment>
+
+               <ui:fragment id="output_message" rendered="#{empty message}">
+                       <div class="errors para">
+                               #{msg.MESSAGE_BOX_PARAMETER_MESSAGE_EMPTY}
+                       </div>
+               </ui:fragment>
+       </div>
+</html>
index 1dbb0f27e20b35a2f3c8d275abd7043e62b9acdd..7550822b2d647723ef910ddef46aa346acfdc51c 100644 (file)
@@ -31,7 +31,7 @@
 
                                                                <div class="table_row">
                                                                        <div class="table_left">
-                                                                               <h:outputLabel for="emailAddress1" value="#{msg.GUEST_REGISTRATION_ENTER_EMAIL1}" />
+                                                                               <h:outputLabel for="emailAddress1" value="#{msg.LOGIN_CHANGE_EMAIL_ENTER_EMAIL1}" />
                                                                        </div>
 
                                                                        <div class="table_right">
@@ -43,7 +43,7 @@
 
                                                                <div class="table_row">
                                                                        <div class="table_left">
-                                                                               <h:outputLabel for="emailAddress2" value="#{msg.GUEST_REGISTRATION_ENTER_EMAIL2}" />
+                                                                               <h:outputLabel for="emailAddress2" value="#{msg.LOGIN_CHANGE_EMAIL_ENTER_EMAIL2}" />
                                                                        </div>
 
                                                                        <div class="table_right">
diff --git a/web/login/login_data_saved.xhtml b/web/login/login_data_saved.xhtml
new file mode 100644 (file)
index 0000000..d4fa96b
--- /dev/null
@@ -0,0 +1,28 @@
+<?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:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_DATA_SAVED}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_LOGIN_DATA_SAVED}
+               </ui:define>
+
+               <ui:define name="content">
+                       <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
+                               <ui:include id="message_box" src="/WEB-INF/templates/generic/message_box.tpl">
+                                       <ui:param name="message" value="#{msg.LOGIN_MESSAGE_DATA_SAVED}" />
+                               </ui:include>
+                       </ui:fragment>
+
+                       <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
+                               <ui:include id="login_only" class="login_only" src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
+                       </ui:fragment>
+               </ui:define>
+       </ui:composition>
+</html>
index eb81f7e87e494dceaf42c0f9538209e99b52af89..456d1d2c92d2cc3b056820c02b53396c36f3d3ca 100644 (file)
@@ -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;
+}