From 501609e3e98803028001f8cf6fe88f4d3f31cffb Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Mon, 15 Aug 2016 11:27:15 +0200
Subject: [PATCH] finally fixed this madness, thanks to @BalusC again: - I
 wanted to have a general ("base") controller that hold methods for every
 controller (bean). - like many controllers do, I want that bean to return
 localized message from my resource bundle and not unlocalized English-only
 messages - this is now done by getting the container's locale and then
 loading the bundle with it's base name (not variable name) - thank you,
 BalusC for enlighten us. :-)

---
 .../jjobs/beans/BaseJobsController.java       | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/java/org/mxchange/jjobs/beans/BaseJobsController.java b/src/java/org/mxchange/jjobs/beans/BaseJobsController.java
index d57534b7..de5289f4 100644
--- a/src/java/org/mxchange/jjobs/beans/BaseJobsController.java
+++ b/src/java/org/mxchange/jjobs/beans/BaseJobsController.java
@@ -18,6 +18,7 @@ package org.mxchange.jjobs.beans;
 
 import java.io.Serializable;
 import java.text.MessageFormat;
+import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import javax.faces.application.FacesMessage;
@@ -131,23 +132,23 @@ public abstract class BaseJobsController implements Serializable {
 		// Both parameter must be valid
 		if (null == clientId) {
 			// Throw NPE
-			throw new NullPointerException("clientId is null");
+			throw new NullPointerException("clientId is null"); //NOI18N
 		} else if (clientId.isEmpty()) {
 			// Is empty
-			throw new IllegalArgumentException("clientId is null");
+			throw new IllegalArgumentException("clientId is null"); //NOI18N
 		} else if (null == i18nKey) {
 			// Throw NPE
-			throw new NullPointerException("i18nKey is null");
+			throw new NullPointerException("i18nKey is null"); //NOI18N
 		} else if (i18nKey.isEmpty()) {
 			// Is empty
-			throw new IllegalArgumentException("i18nKey is null");
+			throw new IllegalArgumentException("i18nKey is null"); //NOI18N
 		}
 
-		// Get facet context
-		FacesContext context = FacesContext.getCurrentInstance();
+		// Get current locale
+		Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
 
-		// Get bundle
-		ResourceBundle bundle = context.getApplication().getResourceBundle(context, "msg"); //NOI18N
+		// Get bundle bundle
+		ResourceBundle bundle = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
 
 		// Default is i18nKey
 		String message = i18nKey;
@@ -161,7 +162,7 @@ public abstract class BaseJobsController implements Serializable {
 		}
 
 		// Get context and add message
-		context.addMessage(clientId, new FacesMessage(message));
+		FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
 	}
 
 }
-- 
2.39.5