]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with rewrite:
authorRoland Häder <roland@mxchange.org>
Mon, 23 May 2016 13:30:19 +0000 (15:30 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 26 May 2016 15:43:55 +0000 (17:43 +0200)
- introduced showFacesMessage()
- rewrote to FacesMessage and not ugly exception 500 error
- rewrote more messages + fixed form ids to naming convention

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/BaseJobsController.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
src/java/org/mxchange/jjobs/beans/email_address/JobsEmailChangeWebSessionBean.java
src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java
src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java
web/WEB-INF/templates/admin/mobile_provider/admin_form_mobile_provider.tpl
web/admin/mobile_provider/admin_mobile_provider_list.xhtml
web/user/login_change_email_address.xhtml

index 6e67552e005f6aa2328b03cce621ecebcc7eb52b..6bb15383995f88b13107a329b7d17f04206b5eb3 100644 (file)
@@ -17,6 +17,8 @@
 package org.mxchange.jjobs.beans;
 
 import java.io.Serializable;
+import java.text.MessageFormat;
+import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
 
 /**
@@ -58,4 +60,19 @@ public abstract class BaseJobsController implements Serializable {
                return isEnabled;
        }
 
+       /**
+        * Shows a faces message for given causing exception. The message from the
+        * exception is being inserted into the message.
+        * <p>
+        * @param clientId Client id to send message to
+        * @param cause Causing exception
+        */
+       protected void showFacesMessage (final String clientId, final Throwable cause) {
+               // Trace message
+               System.out.println(MessageFormat.format("showFacesMessage: clientId={0},cause={1} - CALLED!", clientId, cause));
+
+               // Get context and add message
+               FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(cause.getMessage()));
+       }
+
 }
index 26c1c493222c5fa30f1518277583cd608ce10228..2643123b99a3ad4830aa9b3deb49f84e17bb39b5 100644 (file)
@@ -542,7 +542,8 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
                        throw new FaceletException("Not all required fields are set."); //NOI18N
                } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
                        // Password not matching
-                       throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+                       this.showFacesMessage("login_change_personal_form:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
+                       return ""; //NOI18N
                }
 
                // Get contact instance
index 81e4726938662bb7d74fe2368b47a9e957a95602..acb23c4eced462037aeb193f62cc773c4f51abb5 100644 (file)
@@ -110,7 +110,8 @@ public class JobsEmailChangeWebSessionBean extends BaseJobsController implements
                        throw new FaceletException("Email address 1/2 are mismatching."); //NOI18N
                } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
                        // Password not matching
-                       throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+                       this.showFacesMessage("login_change_email_address_form:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
+                       return ""; //NOI18N
                }
 
                // Get user instance
index c9a178a06c6d904004611ab68de5b1e6b9f39090..f4486b21520f69dfac23f5c14f7bc523649908f8 100644 (file)
@@ -114,7 +114,8 @@ public class JobsAdminMobileProviderWebRequestBean extends BaseJobsController im
                // Is the provider already created?
                if (this.isMobileProviderCreated(mobileProvider)) {
                        // Then throw exception
-                       throw new FaceletException(new MobileProviderAlreadyAddedException(mobileProvider));
+                       this.showFacesMessage("add_mobile_provider_form:providerDialPrefix", new MobileProviderAlreadyAddedException(mobileProvider)); //NOI18N
+                       return ""; //NOI18N
                }
 
                // Init variable
index 071094c0209483541f3d5c875fa4445fe4d7bbaf..41e0a100f6024536e91baded4e67f5cb2e94fe1a 100644 (file)
@@ -102,17 +102,19 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements
                        // Is the email address really not used?
                        user = this.userController.lookupUserByEmailAddress(this.getEmailAddress());
                } catch (final UserEmailAddressNotFoundException ex) {
-                       // Not found, should not happen as the registeredvalidator should find it
+                       // Not found, should not happen as the registered validator should find it
                        throw new FaceletException(MessageFormat.format("this.emailAddress={0} should be resolveable into User instance.", this.getEmailAddress()), ex); //NOI18N
                }
 
                // Is the user account already confirmed?
                if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
                        // Then abort here
-                       throw new FaceletException(new UserStatusConfirmedException(user));
+                       this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusConfirmedException(user)); //NOI18N
+                       return ""; //NOI18N
                } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
                        // User account is locked
-                       throw new FaceletException(new UserStatusLockedException(user));
+                       this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusLockedException(user)); //NOI18N
+                       return ""; //NOI18N
                } else if (user.getUserConfirmKey() == null) {
                        // Status is UNCONFIRMED but confirmation key is NULL
                        throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
index 9bbaf3d1f10c9bcaadaea76a768eff9f360c1259..e6a87ddb1fdd212d0f9b0eb7dd3764ce8f3151f0 100644 (file)
@@ -27,6 +27,8 @@
                                <div class="clear"></div>
                        </div>
 
+                       <h:message for="providerDialPrefix" errorClass="errors" fatalClass="errors" warnClass="errors" />
+
                        <div class="table_row">
                                <div class="table_left_medium">
                                        <h:outputLabel for="providerMailPattern" value="#{msg.ADMIN_ENTER_MOBILE_PROVIDER_PATTERN}" />
index dbd277520f138b8e95d2d9c5b8f42636fe0c0a8f..fdd1d473bed5e0fc4567d73cea93a4ed0148bbb4 100644 (file)
@@ -62,7 +62,7 @@
                                </h:column>
                        </h:dataTable>
 
-                       <h:form id="form_add_mobile_provider">
+                       <h:form id="add_mobile_provider_form">
                                <div class="table_medium">
                                        <div class="table_header">
                                                <h:outputText value="#{msg.ADMIN_ADD_MOBILE_PROVIDER_TITLE}" />
index 4d70ccb0b27f1d5978fd6d39f5c6fe0b7812225c..f6bf9b9769fbd27fa6b488bc57c31d621526129d 100644 (file)
@@ -22,7 +22,7 @@
                                                #{msg.LOGIN_CHANGE_EMAIL_ADDRESS_TITLE}
                                        </div>
 
-                                       <h:form id="login_form">
+                                       <h:form id="login_change_email_address_form">
                                                <div class="para">
                                                        <fieldset id="change_email">
                                                                <legend title="#{msg.LOGIN_CHANGE_EMAIL_LEGEND_TITLE}">#{msg.LOGIN_CHANGE_EMAIL_LEGEND}</legend>