Commit 9c93817a1881257e528de873e54cb47bfc80408d
1 parent
0d573518
Fixed bug with MissingResourceException when user is using locale that is not de…
…fined in stock message bundles.
Showing
1 changed file
with
11 additions
and
2 deletions
@@ -36,12 +36,18 @@ public class ScheduleMessages extends ClientScript { | @@ -36,12 +36,18 @@ public class ScheduleMessages extends ClientScript { | ||
36 | FacesContext facesContext = FacesContext.getCurrentInstance(); | 36 | FacesContext facesContext = FacesContext.getCurrentInstance(); |
37 | Application application = facesContext.getApplication(); | 37 | Application application = facesContext.getApplication(); |
38 | StringBuilder out = new StringBuilder(); | 38 | StringBuilder out = new StringBuilder(); |
39 | - out.append("RichFaces.Schedule.prototype.messages=jQuery.extend(RichFaces.Schedule.prototype.messages,{"); | 39 | +// space at the end is crucial if no locale is supported |
40 | + out.append("RichFaces.Schedule.prototype.messages=jQuery.extend(RichFaces.Schedule.prototype.messages,{ "); | ||
40 | Iterator<Locale> supportedLocales = application.getSupportedLocales(); | 41 | Iterator<Locale> supportedLocales = application.getSupportedLocales(); |
41 | while (supportedLocales.hasNext()) { | 42 | while (supportedLocales.hasNext()) { |
42 | Locale locale = supportedLocales.next(); | 43 | Locale locale = supportedLocales.next(); |
43 | ResourceBundle applicationBundle = ResourceBundle.getBundle(application.getMessageBundle(), locale, loader); | 44 | ResourceBundle applicationBundle = ResourceBundle.getBundle(application.getMessageBundle(), locale, loader); |
44 | - ResourceBundle stockBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale, loader); | 45 | + ResourceBundle stockBundle = null; |
46 | + try { | ||
47 | + stockBundle = ResourceBundle.getBundle(BUNDLE_NAME, locale, loader); | ||
48 | + } catch (MissingResourceException e) { | ||
49 | + LOG.debug("No bundle " + BUNDLE_NAME + " for locale " + locale + " found."); | ||
50 | + } | ||
45 | String[] months = new String[]{"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", | 51 | String[] months = new String[]{"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", |
46 | "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"}; | 52 | "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"}; |
47 | String[] days = new String[]{"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"}; | 53 | String[] days = new String[]{"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"}; |
@@ -121,6 +127,9 @@ public class ScheduleMessages extends ClientScript { | @@ -121,6 +127,9 @@ public class ScheduleMessages extends ClientScript { | ||
121 | try { | 127 | try { |
122 | return applicationBundle.getString(key); | 128 | return applicationBundle.getString(key); |
123 | } catch (MissingResourceException e) { | 129 | } catch (MissingResourceException e) { |
130 | + if (stockBundle == null) { | ||
131 | + throw e; | ||
132 | + } | ||
124 | try { | 133 | try { |
125 | return stockBundle.getString(key); | 134 | return stockBundle.getString(key); |
126 | } catch (MissingResourceException e1) { | 135 | } catch (MissingResourceException e1) { |
Please
register
or
login
to post a comment