From 5b4e3976c3332325b105b33c06d0c5ab8e635b35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 5 Nov 2017 15:02:37 +0100 Subject: [PATCH] Continued a bit: - now there are 3 message bundles: generic, project and local - added public, static method removeBundles() - fixed exception message, the i18nKey was empty, not NULL MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../jcoreee/bean/faces/BaseFacesBean.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java index 15194e3..f9ab2b4 100644 --- a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java +++ b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java @@ -49,7 +49,17 @@ public abstract class BaseFacesBean extends BaseBean { */ static { // Init resource bundle list - RESOURCE_BUNDLES = new ArrayList<>(2); + RESOURCE_BUNDLES = new ArrayList<>(3); + } + + /** + * Removes all bundles from web application. Typically you want to invoke + * this method in a ServletContextListener implemetation on the + * contextDestroyed() method. + */ + public static void removeBundles () { + // Clear bundles + RESOURCE_BUNDLES.clear(); } /** @@ -99,9 +109,6 @@ public abstract class BaseFacesBean extends BaseBean { * @param parameterKey Property key *

* @return Property value - *

- * @throws NullPointerException If given key is not found - * @throws NumberFormatException If no number is given in context parameter */ protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { // Get context parameter @@ -118,6 +125,9 @@ public abstract class BaseFacesBean extends BaseBean { * @param i18nKey I18n key *

* @return Localized message + *

+ * @throws NullPointerException If the parameter is null + * @throws IllegalArgumentException If the parameter is empty */ protected String getMessageFromBundle (final String i18nKey) { // Validate parameter @@ -126,7 +136,7 @@ public abstract class BaseFacesBean extends BaseBean { throw new NullPointerException("i18nKey is null"); //NOI18N } else if (i18nKey.isEmpty()) { // Is empty - throw new IllegalArgumentException("i18nKey is null"); //NOI18N + throw new IllegalArgumentException("i18nKey is empty"); //NOI18N } // Get current locale -- 2.39.5