private String assembleCatalog() { Messages messages = messagesSource.getApplicationCatalog(locale); JSONObject catalog = new JSONObject(); for (String key : messages.getKeys()) { if (key.startsWith("private-")) { continue; } String value = messages.get(key); if (value.contains("%")) { continue; } catalog.put(key, value); } StringBuilder builder = new StringBuilder(2000); builder.append("define(").append(catalog.toString(compactJSON)).append(");"); return builder.toString(); } }
public String getInitialization() { Locale locale = threadLocale.getLocale(); JSONObject spec = new JSONObject(); DateFormatSymbols symbols = new DateFormatSymbols(locale); spec.put("months", new JSONArray((Object[]) symbols.getMonths())); StringBuilder days = new StringBuilder(); String[] weekdays = symbols.getWeekdays(); Calendar c = Calendar.getInstance(locale); int firstDay = c.getFirstDayOfWeek(); // DatePicker needs them in order from monday to sunday. for (int i = Calendar.MONDAY; i <= Calendar.SATURDAY; i++) { days.append(weekdays[i].substring(0, 1)); } days.append(weekdays[Calendar.SUNDAY].substring(0, 1)); spec.put("days", days.toString().toLowerCase(locale)); // jQuery DatePicker widget expects 0 to be sunday. Calendar defines SUNDAY as 1, MONDAY as 2, etc. spec.put("firstDay", firstDay-1); // set language spec.put("language", locale.getLanguage()); // TODO: Skip localization if locale is English? return String.format("Tapestry.DateField.initLocalization(%s);", spec.toString(compactJSON)); }
private String buildRequireJSConfig(List<ModuleConfigurationCallback> callbacks) { // This is the part that can vary from one request to another, based on the capabilities of the client. JSONObject config = baseConfig.copy().put("baseUrl", getBaseURL()); // TAP5-2196: allow changes to the configuration in a per-request basis. for (ModuleConfigurationCallback callback : callbacks) { config = callback.configure(config); assert config != null; } // This part gets written out before any libraries are loaded (including RequireJS). return String.format("var require = %s;\n", config.toString(compactJSON)); }
javaScriptSupport.addScript(InitializationPriority.LATE,"%s('%s').tapestryZone('option',{opt: %s});", jQueryAlias, theSelector, defaultParamsObject.toString(compact));
@Benchmark @Override public Object tapestry() throws Exception { return JSON_SOURCE().streamSerializer().tapestry(JSON_SOURCE().nextPojo()).toString(); }
element.forceAttributes(TapestryConstants.COMPONENT_EVENTS_ATTRIBUTE_NAME, events.toString());
parameters.toString(compactJSON));
addClasses("mixins", filter(componentClassResolver.getMixinNames()), Type.MIXIN, info, object); return new TextStreamResponse("text/javascript", object.toString());