From d0cfebc4036310911b5022bf8fb77ba6c8f9ca95 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Thu, 18 Aug 2011 12:19:16 +0000 Subject: [PATCH] Fixed "no locale" error. --- src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java b/src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java index 5086405..907d3d5 100644 --- a/src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java +++ b/src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java @@ -39,7 +39,9 @@ public class ScheduleMessages extends ClientScript { // space at the end is crucial if no locale is supported out.append("RichFaces.Schedule.prototype.messages=jQuery.extend(RichFaces.Schedule.prototype.messages,{ "); Iterator supportedLocales = application.getSupportedLocales(); + int localeCount = 0; while (supportedLocales.hasNext()) { + localeCount++; Locale locale = supportedLocales.next(); ResourceBundle applicationBundle = ResourceBundle.getBundle(application.getMessageBundle(), locale, loader); ResourceBundle stockBundle = null; @@ -49,11 +51,11 @@ public class ScheduleMessages extends ClientScript { LOG.debug("No bundle " + BUNDLE_NAME + " for locale " + locale + " found."); } String[] months = new String[]{"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", - "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"}; + "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"}; String[] days = new String[]{"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"}; out.append("'").append(locale.toString()).append("':{"); out.append("allDayText:'").append(escape(getMessageFromBundle(MESSAGE_KEY_BASE + "allDay", - applicationBundle, stockBundle))).append("',"); + applicationBundle, stockBundle))).append("',"); appendArray(out, applicationBundle, stockBundle, "monthNames", "monthNames", months); out.append(","); appendArray(out, applicationBundle, stockBundle, "monthNamesShort", "monthNamesShort", months); @@ -63,15 +65,17 @@ public class ScheduleMessages extends ClientScript { appendArray(out, applicationBundle, stockBundle, "dayNamesShort", "dayNamesShort", days); out.append(","); appendMap(out, applicationBundle, stockBundle, "buttonText", "buttonTexts", new String[]{"prev", "next", - "prevYear", "nextYear", "today", "month", "day", "week"}); + "prevYear", "nextYear", "today", "month", "day", "week"}); out.append("},"); } - out.delete(out.length() - 1, out.length()); + if (localeCount > 0) { + out.delete(out.length() - 1, out.length()); + } out.append("})"); try { // TODO where to get encoding from? It should match properties file's encoding, but probably be converted to response encoding return new ByteArrayInputStream(out.toString().getBytes(application.getViewHandler() - .calculateCharacterEncoding(facesContext))); + .calculateCharacterEncoding(facesContext))); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } @@ -110,7 +114,7 @@ public class ScheduleMessages extends ClientScript { for (int i = 0; i < keys.length; i++) { key = MESSAGE_KEY_BASE + prefix + "." + keys[i]; out.append(keys[i]).append(":").append("'").append(escape( - getMessageFromBundle(key, applicationBundle, stockBundle)) + getMessageFromBundle(key, applicationBundle, stockBundle)) ).append("'"); if (i + 1 < keys.length) { out.append(","); -- libgit2 0.24.0