return false;
} else if (!(value instanceof Comparable)) {
// Not castable
- throw new ClassCastException("value is not instance of Comparable");
+ throw new ClassCastException("value is not instance of Comparable"); //NOI18N
}
// Do the cast and compare
// Loop through all
for (final ResourceBundle bundle : getBundles()) {
- // Found message?
// Try it
try {
// Get message
message = bundle.getString(i18nKey);
+
+ // Skip further iterations
break;
} catch (final MissingResourceException ex) {
// Did not find it, ignored
* <p>
* @param clientId Client id to send message to
* @param cause Causing exception
+ * @param severity Severity
*/
- protected void showFacesMessage (final String clientId, final Throwable cause) {
+ protected void showFacesMessage (final String clientId, final Throwable cause, final FacesMessage.Severity severity) {
+ // Both parameter must be valid
+ if (null == clientId) {
+ // Throw NPE
+ throw new NullPointerException("clientId is null"); //NOI18N
+ } else if (clientId.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("clientId is null"); //NOI18N
+ } else if (null == cause) {
+ // Throw NPE
+ throw new NullPointerException("cause is null"); //NOI18N
+ } else if (null == severity) {
+ // Throw NPE
+ throw new NullPointerException("severity is null"); //NOI18N
+ }
+
// Get context and add message
- this.showFacesMessage(clientId, cause.getMessage());
+ this.showFacesMessage(clientId, cause.getMessage(), severity);
}
/**
* <p>
* @param clientId Client id to send message to
* @param i18nKey Message key
+ * @param severity Severity
* <p>
* @throws NullPointerException If clientId or i18nKey is null
* @throws IllegalArgumentException If clientId or i18nKey is empty
*/
- protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException {
+ protected void showFacesMessage (final String clientId, final String i18nKey, final FacesMessage.Severity severity) throws NullPointerException, IllegalArgumentException {
// Both parameter must be valid
if (null == clientId) {
// Throw NPE
} else if (i18nKey.isEmpty()) {
// Is empty
throw new IllegalArgumentException("i18nKey is null"); //NOI18N
+ } else if (null == severity) {
+ // Throw NPE
+ throw new NullPointerException("severity is null"); //NOI18N
}
// Get message from bundle
final String message = this.getMessageFromBundle(i18nKey);
// Get context and add message
- FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
+ FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(severity, message, message));
}
}