From 01c6597129b4c1bb965d154af81c7d87bb57b258 Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 2 Mar 2016 10:35:24 +0100 Subject: [PATCH] Fix display error message --- jscl/src/main/java/jscl/text/ParseException.java | 3 ++- .../org/solovyev/common/msg/AbstractMessage.java | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jscl/src/main/java/jscl/text/ParseException.java b/jscl/src/main/java/jscl/text/ParseException.java index e4dc532a..484a4217 100644 --- a/jscl/src/main/java/jscl/text/ParseException.java +++ b/jscl/src/main/java/jscl/text/ParseException.java @@ -1,5 +1,6 @@ package jscl.text; +import org.solovyev.common.msg.AbstractMessage; import org.solovyev.common.msg.Message; import org.solovyev.common.msg.MessageLevel; import org.solovyev.common.msg.MessageType; @@ -55,7 +56,7 @@ public class ParseException extends Exception implements Message { @Override public String getLocalizedMessage(@Nonnull Locale locale) { final ResourceBundle rb = ResourceBundle.getBundle("jscl/text/msg/messages", locale); - return rb.getString(getMessageCode()); + return AbstractMessage.makeMessage(locale, rb.getString(getMessageCode()), parameters, MessageType.error); } public int getPosition() { diff --git a/jscl/src/main/java/org/solovyev/common/msg/AbstractMessage.java b/jscl/src/main/java/org/solovyev/common/msg/AbstractMessage.java index de59aa8a..13e5752c 100644 --- a/jscl/src/main/java/org/solovyev/common/msg/AbstractMessage.java +++ b/jscl/src/main/java/org/solovyev/common/msg/AbstractMessage.java @@ -118,14 +118,16 @@ public abstract class AbstractMessage implements Message { */ @Nonnull public String getLocalizedMessage(@Nonnull Locale locale) { - String result = null; + return makeMessage(locale, getMessagePattern(locale), parameters, messageLevel); + } - final String messagePattern = getMessagePattern(locale); - if (!Strings.isEmpty(messagePattern)) { - result = Messages.prepareMessage(locale, messagePattern, parameters); + @Nonnull + public static String makeMessage(@Nonnull Locale locale, @Nullable String format, @Nonnull List parameters, @Nonnull MessageLevel messageLevel) { + if (!Strings.isEmpty(format)) { + return Messages.prepareMessage(locale, format, parameters); } - return Strings.getNotEmpty(result, messageLevel.getName() + ": message code = " + messageCode); + return messageLevel.getName() + ": message code = " + format; } @Nonnull