/** * @see org.apache.tapestry.form.translator.AbstractTranslator#parseText(org.apache.tapestry.form.IFormComponent, * ValidationMessages, java.lang.String) */ protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException { Format format = getFormat(messages.getLocale()); try { return format.parseObject(text); } catch (ParseException ex) { throw new ValidatorException(buildMessage(messages, field, getMessageKey()), getConstraint()); } }
public FormatTranslator() { _pattern = defaultPattern(); }
protected String formatObject(IFormComponent field, Locale locale, Object object) { Number number = (Number) object; if (_omitZero) { if (number.doubleValue() == 0) return ""; } return super.formatObject(field, locale, object); }
/** * * {@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); }
/** * @see org.apache.tapestry.form.translator.AbstractTranslator#formatObject(org.apache.tapestry.form.IFormComponent, * Locale, java.lang.Object) */ protected String formatObject(IFormComponent field, Locale locale, Object object) { // Get a new format each time, because (a) have to account for locale and (b) formatters are // not thread safe. Format format = getFormat(locale); return format.format(object); }
/** * * {@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); }
/** * @see org.apache.tapestry.form.translator.AbstractTranslator#formatObject(org.apache.tapestry.form.IFormComponent, * Locale, java.lang.Object) */ protected String formatObject(IFormComponent field, Locale locale, Object object) { // Get a new format each time, because (a) have to account for locale and (b) formatters are // not thread safe. Format format = getFormat(locale); return format.format(object); }
/** * @see org.apache.tapestry.form.translator.AbstractTranslator#parseText(org.apache.tapestry.form.IFormComponent, * ValidationMessages, java.lang.String) */ protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException { Format format = getFormat(messages.getLocale()); try { return format.parseObject(text); } catch (ParseException ex) { throw new ValidatorException(buildMessage(messages, field, getMessageKey()), getConstraint()); } }
public FormatTranslator() { _pattern = defaultPattern(); }
FormComponentContributorContext context, IFormComponent field) super.renderContribution(writer, cycle, context, field);
protected String formatObject(IFormComponent field, Locale locale, Object object) { Number number = (Number) object; if (_omitZero) { if (number.doubleValue() == 0) return ""; } return super.formatObject(field, locale, object); }
public FormatTranslator(String initializer) { PropertyUtils.configureProperties(this, initializer); if (HiveMind.isBlank(_pattern)) { _pattern = defaultPattern(); } }
FormComponentContributorContext context, IFormComponent field) super.renderContribution(writer, cycle, context, field);
public FormatTranslator(String initializer) { PropertyUtils.configureProperties(this, initializer); if (HiveMind.isBlank(_pattern)) { _pattern = defaultPattern(); } }