]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with localization: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Fri, 12 Aug 2016 09:31:00 +0000 (11:31 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 19 Aug 2016 21:06:06 +0000 (23:06 +0200)
- throwing FaceletException causes ugly non-localized messages, better show a nice facet message that has been translated
- it may not happen under condition, but better throw the exception then as something strange is messy
- added missing i18n strings

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/register/JobsUserRegisterWebSessionBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/templates/guest/user/register/guest_form_register_page2.tpl
web/WEB-INF/templates/guest/user/register/guest_form_register_single.tpl

index 0f1310794deee81d3a82e5ccfad52db05416fd35..b9ed26cc779ef22d292961a460dc3545f03c770a 100644 (file)
@@ -129,14 +129,40 @@ public class JobsUserRegisterWebSessionBean extends BaseJobsController implement
                        // Not all required fields are set
                        throw new FaceletException("Not all required fields are set."); //NOI18N
                } else if ((this.featureController.isFeatureEnabled("user_name_required")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
-                       // User name is already used
-                       throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+                       // Is multi-page enabled?
+                       if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
+                               // User name is already used, should not happen here
+                               throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+                       } else {
+                               // May happen here, reset field
+                               this.userController.setUserName(null);
+                               this.showFacesMessage("form_register_single:userName", "ERROR_USER_NAME_ALREADY_USED"); //NOI18N
+                               return ""; //NOI18N
+                       }
                } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
-                       // Email address has already been taken
-                       throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+                       // Is multi-page enabled?
+                       if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
+                               // Email address has already been taken, should not happen here
+                               throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+                       } else {
+                               // May happen here, reset fields
+                               this.contactController.setEmailAddress(null);
+                               this.contactController.setEmailAddressRepeat(null);
+                               this.showFacesMessage("form_register_single:emailAddressRepeat", "ERROR_EMAIL_ADDRESS_ALREADY_USED"); //NOI18N
+                               return ""; //NOI18N
+                       }
                } else if (!this.contactController.isSameEmailAddressEntered()) {
-                       // Not same email address entered
-                       throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
+                       // Is multi-page enabled?
+                       if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
+                               // Not same email address entered, should not happen here
+                               throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
+                       } else {
+                               // May happen here, reset fields
+                               this.contactController.setEmailAddress(null);
+                               this.contactController.setEmailAddressRepeat(null);
+                               this.showFacesMessage("form_register_single:emailAddressRepeat", "ERROR_EMAIL_ADDRESSES_MISMATCHING"); //NOI18N
+                               return ""; //NOI18N
+                       }
                } else if (!this.userController.isSamePasswordEntered()) {
                        // Not same password entered
                        throw new FaceletException(new DataRepeatMismatchException("Passwords not matching.")); //NOI18N
@@ -200,11 +226,16 @@ public class JobsUserRegisterWebSessionBean extends BaseJobsController implement
                        // user must be set
                        throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
                } else if ((this.featureController.isFeatureEnabled("user_name_required")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
-                       // User name is already used
-                       throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+                       // User name is already used, so clear it
+                       this.userController.setUserName(null);
+                       this.showFacesMessage("form_register_page1:userName", "ERROR_USER_NAME_ALREADY_USED"); //NOI18N
+                       return ""; //NOI18N
                } else if (!this.contactController.isSameEmailAddressEntered()) {
-                       // Not same email address entered
-                       throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
+                       // Not same email address entered, clear both
+                       this.contactController.setEmailAddress(null);
+                       this.contactController.setEmailAddressRepeat(null);
+                       this.showFacesMessage("form_register_page1:emailAddressRepeat", "ERROR_EMAIL_ADDRESSES_MISMATCHING"); //NOI18N
+                       return ""; //NOI18N
                }
 
                // Create half contact instance with email address
@@ -216,8 +247,11 @@ public class JobsUserRegisterWebSessionBean extends BaseJobsController implement
 
                // Check if email address is registered
                if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
-                       // Email address has already been taken
-                       throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+                       // Email address has already been taken, clear both
+                       this.contactController.setEmailAddress(null);
+                       this.contactController.setEmailAddressRepeat(null);
+                       this.showFacesMessage("form_register_page1:emailAddress", "ERROR_EMAIL_ADDRESS_ALREADY_USED"); //NOI18N
+                       return ""; //NOI18N
                }
 
                // Now only redirect to next page as the JSF does it
index 0e40c412b03993e76213525a444b09e50f6326bf..addfdd7e4fd0217343da834f94a8c6a7948cff56 100644 (file)
@@ -33,7 +33,6 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jjobs.beans.BaseJobsController;
 import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController;
 import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
@@ -73,11 +72,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
         */
        private static final long serialVersionUID = 542_145_347_916L;
 
-       /**
-        * Contact EJB
-        */
-       private ContactSessionBeanRemote contactBean;
-
        /**
         * General contact controller
         */
@@ -168,9 +162,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
                        // Try to lookup
                        this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-
-                       // Try to lookup
-                       this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
                } catch (final NamingException e) {
                        // Throw again
                        throw new FaceletException(e);
index 2f7f09f9b9830b34a95b848a7e2f74a24b3a1581..c2b503af1606a1258eaad512a0a56eb93d396b21 100644 (file)
@@ -637,3 +637,6 @@ ERROR_USER_NEW_PASSWORD_ALREADY_ENTERED=Sie hatten vor kurzem das Passwort berei
 ERROR_USER_NOT_FOUND=Benutzeraccount nicht gefunden.
 ERROR_USER_STATUS_UNCONFIRMED=Sie haben noch nicht Ihren Benutzeraccount best\u00e4tigt.
 ERROR_USER_PASSWORD_MISMATCH=Ihr eingegebenes Passwort ist falsch.
+ERROR_USER_NAME_ALREADY_USED=Benutzername bereits verwendet. Bitte geben Sie einen anderen ein.
+ERROR_EMAIL_ADDRESSES_MISMATCHING=Die eingegebenen  Email-Addressen stimmen nicht \u00fcberein.
+ERROR_EMAIL_ADDRESS_ALREADY_USED=Die eingegebene Email-Adresse wird bereits verwendet und kann nicht erneut verwendet werden.
index 6723b59b4d012c9de4afcc4c49108abeb57fd64e..4fdb2a2dd57232a74c8358367117fa3a68ef56ec 100644 (file)
@@ -637,3 +637,6 @@ ERROR_USER_NEW_PASSWORD_ALREADY_ENTERED=You have already entered this password s
 ERROR_USER_NOT_FOUND=User account not found.
 ERROR_USER_STATUS_UNCONFIRMED=You have not yet confirmed your user account.
 ERROR_USER_PASSWORD_MISMATCH=You have entered a wrong password.
+ERROR_USER_NAME_ALREADY_USED=User name already used. Please enter another name.
+ERROR_EMAIL_ADDRESSES_MISMATCHING=Both entered email addresses are not the same.
+ERROR_EMAIL_ADDRESS_ALREADY_USED=YOur entered email address is already used. Please enter another and try again.
index dd4a36287d2c147e791cd89d09077d054d9ef8de..b62cf97ea2e9b0a26041871d945d38d457d9b16e 100644 (file)
@@ -15,7 +15,7 @@
 
                        <div class="table_footer">
                                <h:commandButton styleClass="reset right_space" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
-                               <h:commandButton styleClass="submit" type="submit" id="finish_registration" value="#{msg.BUTTON_FINISH_REGISTRATION}" action="#{registerController.doFinishRegistration()}" />
+                               <h:commandButton styleClass="submit" type="submit" value="#{msg.BUTTON_FINISH_REGISTRATION}" action="#{registerController.doFinishRegistration()}" />
                        </div>
                </div>
        </h:form>
index 04c19d55a9903529d47f595507d70c6efc9dd485..1b084bd5e49f918bfceaa50852ef061a3ebd973c 100644 (file)
 
                                                        <div class="clear"></div>
                                                </div>
+
+                                               <div class="error_container">
+                                                       <h:message for="userName" errorClass="errors" fatalClass="errors" warnClass="errors" />
+                                               </div>
                                        </ui:fragment>
 
                                        <ui:include src="/WEB-INF/templates/guest/guest_email_address_repeat_fields.tpl" />