package org.mxchange.pizzaapplication.beans.user;
import java.text.MessageFormat;
+import java.util.Locale;
import java.util.Objects;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
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.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.setUserProfileMode(ProfileMode.INVISIBLE);
// Copy user locale
- newUser.setUserLocale(this.localizationController.getLocale());
+ newUser.setUserLocale(this.getLocale());
// 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>
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Objects;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
@Inject
private PizzaFeaturesWebApplicationController featureController;
+ /**
+ * Locale instance
+ */
+ private Locale locale;
+
/**
* Localization controller
*/
this.copyUser(user);
}
+ /**
+ * 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 when user confirmed account.
* <p>
// Set user name profile mode and locale
user.setUserName(this.getUserName());
user.setUserProfileMode(this.getUserProfileMode());
- user.setUserLocale(this.localizationController.getLocale());
+ user.setUserLocale(this.getLocale());
// Is multiple registration page
if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
this.setUserProfileMode(user.getUserProfileMode());
}
+ /**
+ * 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;
+ }
+
/**
* Removes user from all lists
* <p>
*/
package org.mxchange.pizzaapplication.beans.user.resendlink;
+import java.util.Locale;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
import javax.enterprise.inject.Any;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
*/
private String emailAddress;
+ /**
+ * Locale instance
+ */
+ private Locale locale;
+
/**
* Localization controller
*/
super();
}
+ /**
+ * 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());
+ }
+
/**
* Resends (new) confirmation link to given email address, if found.
* Otherwise an exception is thrown. On success a redirect takes place.
String baseUrl = FacesUtils.generateBaseUrl();
// Call EJB and return redirect target
- managedUser = this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+ managedUser = this.resendLinkBean.resendConfirmationLink(user, this.getLocale(), baseUrl);
} catch (final UserNotFoundException ex) {
// User not found
this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N
this.emailAddress = emailAddress;
}
+ /**
+ * 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;
+ }
+
/**
* Post-construction method
*/