From: Roland Häder Date: Sat, 19 Aug 2017 13:19:25 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3b1cda79a1628260d0fe1d19919b06fde9e03978;p=jfinancials-war.git Please cherry-pick: - notifying a RequestScoped (partly including ViewScoped) bean about a locale change will not last long, better is to get the then changed locale from the view root again Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java index 0b590192..babe224a 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java @@ -25,6 +25,7 @@ import javax.enterprise.event.Event; import javax.enterprise.event.Observes; import javax.enterprise.inject.Any; import javax.faces.FacesException; +import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; @@ -32,13 +33,11 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent; import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController; import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionController; import org.mxchange.jfinancials.beans.helper.FinancialsWebRequestHelperController; -import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; @@ -125,17 +124,6 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController @Any private Event deleteUserEvent; - /** - * Locale instance - */ - private Locale locale; - - /** - * Localization controller - */ - @Inject - private FinancialsLocalizationSessionController localizationController; - /** * An event fired when the administrator has updated a new user */ @@ -248,8 +236,11 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController newUser.setUserAccountStatus(UserAccountStatus.CONFIRMED); newUser.setUserProfileMode(ProfileMode.INVISIBLE); + // Get locale from view-root + Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); + // Copy user locale - newUser.setUserLocale(this.getLocale()); + newUser.setUserLocale(locale); // Init instance Contact userContact; @@ -359,26 +350,6 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController this.setUser(event.getCreatedUser()); } - /** - * Observer method for events being fired when the application's locale has - * been changed. - *

- * @param event Event being fired - */ - public void afterLocaleChangeEvent (@Observes final ObservableLocaleChangeEvent event) { - // Is the parameter valid? - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); - } else if (event.getLocale() == null) { - // Throw NPE again - throw new NullPointerException("event.locale is null"); - } - - // Set it here - this.setLocale(event.getLocale()); - } - /** * Event observer for new user registrations *

@@ -795,24 +766,6 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController this.setUserName(null); } - /** - * Getter for locale instance - *

- * @return Locale instance - */ - private Locale getLocale () { - return this.locale; - } - - /** - * Setter for locale instance - *

- * @param locale Locale instance - */ - private void setLocale (final Locale locale) { - this.locale = locale; - } - /** * Checks if same password is entered and that they are not empty. *

diff --git a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java index 8e26fa65..b8db6c8a 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java @@ -1081,6 +1081,7 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple // - other data this.clearUserName(); this.clearUserPasswords(); + this.setLocale(null); } /**