/** * @see org.apache.tapestry.form.translator.FormatTranslator#getFormat(java.util.Locale) */ protected Format getFormat(Locale locale) { return getDateFormat(locale); }
public SimpleDateFormat getDateFormat(Locale locale) { SimpleDateFormat ret = new SimpleDateFormat(getPattern(), new DateFormatSymbols(locale)); ret.setLenient(_lenient); return ret; }
/** * * {@inheritDoc} */ public void renderContribution(IMarkupWriter writer, IRequestCycle cycle, FormComponentContributorContext context, IFormComponent field) { super.renderContribution(writer, cycle, context, field); String message = buildMessage(context, field, getMessageKey()); JSONObject profile = context.getProfile(); if (!profile.has(ValidationConstants.CONSTRAINTS)) { profile.put(ValidationConstants.CONSTRAINTS, new JSONObject()); } JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS); context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");"); accumulateProperty(cons, field.getClientId(), new JSONLiteral("[tapestry.form.datetime.isValidDate,{" + "datePattern:" + JSONObject.quote(getPattern()) + (isLenient() ? "" : ",strict:true") + "}]")); accumulateProfileProperty(field, profile, ValidationConstants.CONSTRAINTS, message); }
new JSONLiteral("[tapestry.form.datetime.isValidDate,{" + "max:" + JSONObject.quote(translator.format(field, context.getLocale(), _maxDate)) + "," + "datePattern:" + JSONObject.quote(translator.getPattern()) + (translator.isLenient() ? "" : ",strict:true") + "}]"));
json.put("inputName", getName()); json.put("iconAlt", getIconAlt()); json.put("displayFormat", translator.getPattern(getPage().getLocale())); json.put("saveFormat", translator.getPattern(getPage().getLocale())); json.put("value", translator.formatRfc3339(getValue()));
private String buildMessage(ValidationMessages messages, IFormComponent field, DateTranslator translator) { return messages.formatValidationMessage( getMessage(), ValidationStrings.DATE_TOO_LATE, new Object[] { field.getDisplayName(), (translator != null) ? translator.format(field, messages.getLocale(), _maxDate) : _maxDate.toString()}); }
/** * * {@inheritDoc} */ public void renderContribution(IMarkupWriter writer, IRequestCycle cycle, FormComponentContributorContext context, IFormComponent field) { super.renderContribution(writer, cycle, context, field); String message = buildMessage(context, field, getMessageKey()); JSONObject profile = context.getProfile(); if (!profile.has(ValidationConstants.CONSTRAINTS)) { profile.put(ValidationConstants.CONSTRAINTS, new JSONObject()); } JSONObject cons = profile.getJSONObject(ValidationConstants.CONSTRAINTS); context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");"); accumulateProperty(cons, field.getClientId(), new JSONLiteral("[tapestry.form.datetime.isValidDate,{" + "datePattern:" + JSONObject.quote(getPattern()) + (isLenient() ? "" : ",strict:true") + "}]")); accumulateProfileProperty(field, profile, ValidationConstants.CONSTRAINTS, message); }
new JSONLiteral("[tapestry.form.datetime.isValidDate,{" + "min:" + JSONObject.quote(translator.format(field, context.getLocale(), _minDate)) + "," + "datePattern:" + JSONObject.quote(translator.getPattern()) + (translator.isLenient() ? "" : ",strict:true") + "}]"));
json.put("inputName", getName()); json.put("iconAlt", getIconAlt()); json.put("displayFormat", translator.getPattern(getPage().getLocale())); json.put("saveFormat", translator.getPattern(getPage().getLocale())); json.put("value", translator.formatRfc3339(getValue()));
private String buildMessage(ValidationMessages messages, IFormComponent field, DateTranslator translator) { return messages.formatValidationMessage( getMessage(), ValidationStrings.DATE_TOO_LATE, new Object[] { field.getDisplayName(), (translator != null) ? translator.format(field, messages.getLocale(), _maxDate) : _maxDate.toString()}); }
new JSONLiteral("[tapestry.form.datetime.isValidDate,{" + "min:" + JSONObject.quote(translator.format(field, context.getLocale(), _minDate)) + "," + "datePattern:" + JSONObject.quote(translator.getPattern()) + (translator.isLenient() ? "" : ",strict:true") + "}]"));
json.put("inputName", getName()); json.put("iconAlt", getIconAlt()); json.put("displayFormat", translator.getPattern(getPage().getLocale())); json.put("saveFormat", translator.getPattern(getPage().getLocale())); json.put("value", translator.formatRfc3339(getValue())); json.put("adjustWeeks", isAdjustWeeks()); if (getStartDate() != null) json.put("startDate", translator.formatRfc3339(getStartDate())); if (getEndDate() != null) json.put("endDate", translator.formatRfc3339(getEndDate())); if (getWeekStartsOn() > -1) json.put("weekStartsOn", getWeekStartsOn());
/** * @see org.apache.tapestry.form.translator.FormatTranslator#getFormat(java.util.Locale) */ protected Format getFormat(Locale locale) { return getDateFormat(locale); }
private String buildMessage(ValidationMessages messages, IFormComponent field, DateTranslator translator) { return messages.formatValidationMessage( getMessage(), ValidationStrings.DATE_TOO_EARLY, new Object[] { field.getDisplayName(), (translator != null) ? translator.format(field, messages.getLocale(), _minDate) : _minDate.toString()}); }
public SimpleDateFormat getDateFormat(Locale locale) { SimpleDateFormat ret = new SimpleDateFormat(getPattern(), new DateFormatSymbols(locale)); ret.setLenient(_lenient); return ret; }
new JSONLiteral("[tapestry.form.datetime.isValidDate,{" + "max:" + JSONObject.quote(translator.format(field, context.getLocale(), _maxDate)) + "," + "datePattern:" + JSONObject.quote(translator.getPattern()) + (translator.isLenient() ? "" : ",strict:true") + "}]"));
json.put("inputName", getName()); json.put("iconAlt", getIconAlt()); json.put("displayFormat", translator.getPattern(getPage().getLocale())); json.put("saveFormat", translator.getPattern(getPage().getLocale())); json.put("value", translator.formatRfc3339(getValue())); json.put("adjustWeeks", isAdjustWeeks()); if (getStartDate() != null) json.put("startDate", translator.formatRfc3339(getStartDate())); if (getEndDate() != null) json.put("endDate", translator.formatRfc3339(getEndDate())); if (getWeekStartsOn() > -1) json.put("weekStartsOn", getWeekStartsOn());
/** * @see org.apache.tapestry.form.translator.AbstractTranslator#getMessageParameters(java.util.Locale, * java.lang.String) */ protected Object[] getMessageParameters(Locale locale, String label) { String pattern = getDateFormat(locale).toLocalizedPattern().toUpperCase(locale); return new Object[] { label, pattern }; }
private String buildMessage(ValidationMessages messages, IFormComponent field, DateTranslator translator) { return messages.formatValidationMessage( getMessage(), ValidationStrings.DATE_TOO_EARLY, new Object[] { field.getDisplayName(), (translator != null) ? translator.format(field, messages.getLocale(), _minDate) : _minDate.toString()}); }
/** * @see org.apache.tapestry.form.translator.AbstractTranslator#getMessageParameters(java.util.Locale, * java.lang.String) */ protected Object[] getMessageParameters(Locale locale, String label) { String pattern = getDateFormat(locale).toLocalizedPattern().toUpperCase(locale); return new Object[] { label, pattern }; }