+ /**
+ * Returns a message based on given i18nKey or puts it into three question
+ * marks each side when not found.
+ * <p>
+ * @param i18nKey I18n key
+ * <p>
+ * @return Localized message
+ * <p>
+ * @throws NullPointerException If the parameter is null
+ * @throws IllegalArgumentException If the parameter is empty
+ */
+ protected String getMessageFromBundle (final String i18nKey) {
+ // Validate parameter
+ if (null == i18nKey) {
+ // Throw NPE
+ throw new NullPointerException("i18nKey is null"); //NOI18N
+ } else if (i18nKey.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("i18nKey is empty"); //NOI18N
+ }
+
+ // Get current locale
+ final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
+
+ // Get bundle bundle
+ this.loadResourceBundles(locale);
+
+ // Default is i18nKey
+ String message = MessageFormat.format("???{0}???", i18nKey); //NOI18N
+
+ // Loop through all
+ for (final ResourceBundle bundle : getBundles()) {
+ // Found message?
+ // Try it
+ try {
+ // Get message
+ message = bundle.getString(i18nKey);
+ break;
+ } catch (final MissingResourceException ex) {
+ // Did not find it, ignored
+ }
+ }
+
+ // Return it
+ return message;
+ }
+