Binding defaultFormat() { return new AbstractBinding(resources.getLocation()) { @Override public boolean isInvariant() { return false; } public Object get() { DateFormat shortDateFormat = time ? DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale) : DateFormat.getDateInstance(DateFormat.SHORT, locale); if (shortDateFormat instanceof SimpleDateFormat) { SimpleDateFormat simpleDateFormat = (SimpleDateFormat) shortDateFormat; String pattern = simpleDateFormat.toPattern(); String revised = pattern.replaceAll("(?<!y)yy(?!y)", "yyyy"); return new SimpleDateFormat(revised); } return shortDateFormat; } }; }
Binding defaultTime() { return new AbstractBinding(resources.getLocation()) { public Object get() { return annotationProvider.getAnnotation(TimeSignificant.class) != null; } }; }
public void beginRender(MarkupWriter writer) { String value = tracker.getInput(this); if (value == null) { value = formatCurrentValue(); } String clientId = getClientId(); String triggerId = clientId + "-trigger"; writer.element( "input", "type", hideTextField ? "hidden" : "text", "name", getControlName(), "id", clientId, "value", value); if (isDisabled()) { writer.attributes("disabled", "disabled"); } validate.render(writer); resources.renderInformalParameters(writer); decorateInsideField(); writer.end(); // Now the trigger icon. writer.element( "img", "id", triggerId, "class", "t-calendar-trigger", "src", icon.toClientURL(), "alt", "[Show]"); writer.end(); // img writeTimeZone(writer); JSONObject spec = new JSONObject( "clientId", clientId, "clientDateFormat", formatConverter.convertToClient(format)) .put("time", time) .put("singleClick", singleClick); if (max != null) { spec.put("max", convertDateToClientTimeZone(max).getTime()); } if (min != null) { spec.put("min", convertDateToClientTimeZone(min).getTime()); } javascriptSupport.addInitializerCall("tapxDateField", spec); }