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;
import org.mxchange.addressbook.beans.helper.AddressbookWebRequestHelperController;
import org.mxchange.addressbook.beans.localization.AddressbookLocalizationSessionController;
import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
@Any
private Event<ObservableAdminDeletedUserEvent> deleteUserEvent;
- /**
- * Locale instance
- */
- private Locale locale;
-
/**
* Localization controller
*/
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;
this.setUser(event.getCreatedUser());
}
- /**
- * Observer method for events being fired when the application's locale has
- * been changed.
- * <p>
- * @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
* <p>
this.setUserName(null);
}
- /**
- * Getter for locale instance
- * <p>
- * @return Locale instance
- */
- private Locale getLocale () {
- return this.locale;
- }
-
- /**
- * Setter for locale instance
- * <p>
- * @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.
* <p>