Commit d0cfebc4036310911b5022bf8fb77ba6c8f9ca95

Authored by bernard
1 parent 9c93817a

Fixed "no locale" error.

... ... @@ -39,7 +39,9 @@ public class ScheduleMessages extends ClientScript {
39 39 // space at the end is crucial if no locale is supported
40 40 out.append("RichFaces.Schedule.prototype.messages=jQuery.extend(RichFaces.Schedule.prototype.messages,{ ");
41 41 Iterator<Locale> supportedLocales = application.getSupportedLocales();
  42 + int localeCount = 0;
42 43 while (supportedLocales.hasNext()) {
  44 + localeCount++;
43 45 Locale locale = supportedLocales.next();
44 46 ResourceBundle applicationBundle = ResourceBundle.getBundle(application.getMessageBundle(), locale, loader);
45 47 ResourceBundle stockBundle = null;
... ... @@ -49,11 +51,11 @@ public class ScheduleMessages extends ClientScript {
49 51 LOG.debug("No bundle " + BUNDLE_NAME + " for locale " + locale + " found.");
50 52 }
51 53 String[] months = new String[]{"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST",
52   - "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"};
  54 + "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"};
53 55 String[] days = new String[]{"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"};
54 56 out.append("'").append(locale.toString()).append("':{");
55 57 out.append("allDayText:'").append(escape(getMessageFromBundle(MESSAGE_KEY_BASE + "allDay",
56   - applicationBundle, stockBundle))).append("',");
  58 + applicationBundle, stockBundle))).append("',");
57 59 appendArray(out, applicationBundle, stockBundle, "monthNames", "monthNames", months);
58 60 out.append(",");
59 61 appendArray(out, applicationBundle, stockBundle, "monthNamesShort", "monthNamesShort", months);
... ... @@ -63,15 +65,17 @@ public class ScheduleMessages extends ClientScript {
63 65 appendArray(out, applicationBundle, stockBundle, "dayNamesShort", "dayNamesShort", days);
64 66 out.append(",");
65 67 appendMap(out, applicationBundle, stockBundle, "buttonText", "buttonTexts", new String[]{"prev", "next",
66   - "prevYear", "nextYear", "today", "month", "day", "week"});
  68 + "prevYear", "nextYear", "today", "month", "day", "week"});
67 69 out.append("},");
68 70 }
69   - out.delete(out.length() - 1, out.length());
  71 + if (localeCount > 0) {
  72 + out.delete(out.length() - 1, out.length());
  73 + }
70 74 out.append("})");
71 75 try {
72 76 // TODO where to get encoding from? It should match properties file's encoding, but probably be converted to response encoding
73 77 return new ByteArrayInputStream(out.toString().getBytes(application.getViewHandler()
74   - .calculateCharacterEncoding(facesContext)));
  78 + .calculateCharacterEncoding(facesContext)));
75 79 } catch (UnsupportedEncodingException e) {
76 80 throw new RuntimeException(e);
77 81 }
... ... @@ -110,7 +114,7 @@ public class ScheduleMessages extends ClientScript {
110 114 for (int i = 0; i < keys.length; i++) {
111 115 key = MESSAGE_KEY_BASE + prefix + "." + keys[i];
112 116 out.append(keys[i]).append(":").append("'").append(escape(
113   - getMessageFromBundle(key, applicationBundle, stockBundle))
  117 + getMessageFromBundle(key, applicationBundle, stockBundle))
114 118 ).append("'");
115 119 if (i + 1 < keys.length) {
116 120 out.append(",");
... ...
Please register or login to post a comment