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;
// 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;
}
// Get context and add message
- context.addMessage(clientId, new FacesMessage(message));
+ FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
}
}