boolean beginRender(MarkupWriter writer) { final Field field = this.field; decorator.beforeLabel(field); labelElement = writer.element("label"); resources.renderInformalParameters(writer); // Since we don't know if the field has rendered yet, we need to defer writing the for and id // attributes until we know the field has rendered (and set its clientId property). That's // exactly what Heartbeat is for. Runnable command = new Runnable() { public void run() { String fieldId = field.getClientId(); labelElement.forceAttributes("for", fieldId, "id", fieldId + ":label"); decorator.insideLabel(field, labelElement); } }; heartbeat.defer(command); return !ignoreBody; }
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(); } }
/** * Render the upload tags. * * @param writer Writer to output markup */ protected void beginRender(MarkupWriter writer) { formSupport.setEncodingType(MULTIPART_ENCTYPE); writer.element( "input", "type", "file", "name", getControlName(), "id", getClientId(), "class", cssClass); validate.render(writer); resources.renderInformalParameters(writer); decorateInsideField(); // TAPESTRY-2453 if (request.isXHR()) { javaScriptSupport.require("t5/core/injected-upload").with(getClientId()); } }
/** 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); }
void beginRender(MarkupWriter writer) { writer.element("select", "name", getControlName(), "id", getClientId()); putPropertyNameIntoBeanValidationContext("value"); validate.render(writer); removePropertyNameFromBeanValidationContext(); resources.renderInformalParameters(writer); decorateInsideField(); // Disabled is via a mixin if (this.zone != null) { Link link = resources.createEventLink(CHANGE_EVENT); JSONObject spec = new JSONObject("selectId", getClientId(), "zoneId", zone, "url", link.toURI()); javascriptSupport.addInitializerCall("linkSelectToZone", spec); } }
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); }