From 9c93817a1881257e528de873e54cb47bfc80408d Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Tue, 19 Apr 2011 15:03:35 +0000 Subject: [PATCH] Fixed bug with MissingResourceException when user is using locale that is not defined in stock message bundles. --- src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 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 d511249..5086405 100644 --- a/src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java +++ b/src/main/java/org/richfaces/renderkit/html/scripts/ScheduleMessages.java @@ -36,12 +36,18 @@ public class ScheduleMessages extends ClientScript { FacesContext facesContext = FacesContext.getCurrentInstance(); Application application = facesContext.getApplication(); StringBuilder out = new StringBuilder(); - out.append("RichFaces.Schedule.prototype.messages=jQuery.extend(RichFaces.Schedule.prototype.messages,{"); +// 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(); while (supportedLocales.hasNext()) { Locale locale = supportedLocales.next(); ResourceBundle applicationBundle = ResourceBundle.getBundle(application.getMessageBundle(), locale, loader); - ResourceBundle stockBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale, loader); + ResourceBundle stockBundle = null; + try { + stockBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale, loader); + } catch (MissingResourceException e) { + 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"}; String[] days = new String[]{"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"}; @@ -121,6 +127,9 @@ public class ScheduleMessages extends ClientScript { try { return applicationBundle.getString(key); } catch (MissingResourceException e) { + if (stockBundle == null) { + throw e; + } try { return stockBundle.getString(key); } catch (MissingResourceException e1) { -- libgit2 0.24.0