Commit d0cfebc4036310911b5022bf8fb77ba6c8f9ca95

Authored by bernard
1 parent 9c93817a

Fixed "no locale" error.

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