void afterRender(MarkupWriter writer) { // If the Label element has a body that renders some non-blank output, that takes precendence // over the label string provided by the field. boolean bodyIsBlank = InternalUtils.isBlank(labelElement.getChildMarkup()); if (bodyIsBlank) writer.write(field.getLabel()); writer.end(); // label decorator.afterLabel(field); }
private void writeTimeZone(MarkupWriter writer) { if (timeZone == TimeZoneVisibility.NONE) return; TimeZone tz = timeZoneTracker.getClientTimeZone(); writer.element("span", "class", "tx-datefield-timezone"); switch (timeZone) { case DISPLAY: writer.write(" "); writer.write(tz.getDisplayName(locale)); break; case SELECT: writer.element("select", "name", getControlName() + "$timezone"); for (TimeZone option : F.flow(TimeZone.getAvailableIDs()).map(ID_TO_TIME_ZONE).sort(timeZoneComparator)) { writer.element("option", "value", option.getID()); if (tz.equals(option)) writer.attributes("selected", "selected"); int offset = option.getRawOffset() / (1000 * 60 * 60); writer.write(String.format("UTC%+03d %s", offset, option.getID())); writer.end(); } writer.end(); default: break; } writer.end(); }
/** * Writes an icon for field after the field. The icon has the same id as the field, with ":icon" * appended. This is expected by the default client-side JavaScript. The icon's src is a blank * spacer image (this is to allow the image displayed to be overridden via CSS). The icon's CSS * class is "t-error-icon", with "t-invisible" added if the field is not in error when rendered. * If client validation is not enabled for the form containing the field and the field is not in * error, then the error icon itself is not rendered. * * @param field which just completed rendering itself */ @Override public void afterField(Field field) { boolean inError = inError(field); boolean clientValidationEnabled = getFormSupport().isClientValidationEnabled(); if (inError || clientValidationEnabled) { String iconId = field.getClientId() + "_icon"; String cssClass = inError ? "t-error-icon" : "t-error-icon t-invisible"; markupWriter.element( "img", "src", spacerAsset.toClientURL(), "alt", "", "class", cssClass, "id", iconId); markupWriter.end(); } }
/** Renders the options, including the blank option. */ @BeforeRenderTemplate void options(MarkupWriter writer) { selectedClientValue = tracker.getInput(this); // Use the value passed up in the form submission, if available. // Failing that, see if there is a current value (via the value parameter), and // convert that to a client value for later comparison. if (selectedClientValue == null) selectedClientValue = value == null ? null : encoder.toClient(value); if (showBlankOption()) { writer.element("option", "value", ""); writer.write(blankLabel); writer.end(); } SelectModelVisitor renderer = new Renderer(writer); model.visit(renderer); }
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); }
public void afterRender(MarkupWriter writer) { writer.end(); }