From: Roland Häder Date: Mon, 23 May 2016 13:30:19 +0000 (+0200) Subject: Continued with rewrite: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bfb4b503b6d3e2ec826f068cb0a244b54815b280;p=jfinancials-war.git Continued with rewrite: - introduced showFacesMessage() - rewrote to FacesMessage and not ugly exception 500 error - rewrote more messages + fixed form ids to naming convention --- diff --git a/src/java/org/mxchange/addressbook/beans/BaseAddressbookController.java b/src/java/org/mxchange/addressbook/beans/BaseAddressbookController.java index bee8b0ac..4b9c3ffc 100644 --- a/src/java/org/mxchange/addressbook/beans/BaseAddressbookController.java +++ b/src/java/org/mxchange/addressbook/beans/BaseAddressbookController.java @@ -17,6 +17,8 @@ package org.mxchange.addressbook.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 BaseAddressbookController implements Serializable { return isEnabled; } + /** + * Shows a faces message for given causing exception. The message from the + * exception is being inserted into the message. + *

+ * @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())); + } + } diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java index bf8d7ed6..adbda5c4 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java @@ -544,7 +544,8 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController 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 diff --git a/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java index b27e3bfd..456052cf 100644 --- a/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java @@ -110,7 +110,8 @@ public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookControl throw new FaceletException("Email address 1/2 are mismatching."); //NOI18N } else if (!this.loginController.ifCurrentPasswordMatches()) { // Password not matching - throw new FaceletException(new UserPasswordMismatchException(this.loginController.getLoggedInUser())); + this.showFacesMessage("login_change_email_address_form:currentPassword", new UserPasswordMismatchException(this.loginController.getLoggedInUser())); //NOI18N + return ""; //NOI18N } // Get user instance diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java index 3ba0d243..0b54fdca 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java @@ -114,7 +114,8 @@ public class AddressbookAdminMobileProviderWebRequestBean extends BaseAddressboo // 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 diff --git a/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java index b8ec7c65..c2c08653 100644 --- a/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java @@ -102,17 +102,19 @@ public class AddressbookResendLinkWebSessionBean extends BaseAddressbookControll // 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 diff --git a/web/WEB-INF/templates/admin/mobile_provider/admin_form_mobile_provider.tpl b/web/WEB-INF/templates/admin/mobile_provider/admin_form_mobile_provider.tpl index 9bbaf3d1..e6a87ddb 100644 --- a/web/WEB-INF/templates/admin/mobile_provider/admin_form_mobile_provider.tpl +++ b/web/WEB-INF/templates/admin/mobile_provider/admin_form_mobile_provider.tpl @@ -27,6 +27,8 @@

+ +
diff --git a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml index dbd27752..fdd1d473 100644 --- a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml +++ b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml @@ -62,7 +62,7 @@ - +
diff --git a/web/user/login_change_email_address.xhtml b/web/user/login_change_email_address.xhtml index ed55ac8b..475d96f6 100644 --- a/web/user/login_change_email_address.xhtml +++ b/web/user/login_change_email_address.xhtml @@ -22,7 +22,7 @@ #{msg.LOGIN_CHANGE_EMAIL_ADDRESS_TITLE}
- +
#{msg.LOGIN_CHANGE_EMAIL_LEGEND}