Exemple #1
0
  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;
  }
Exemple #2
0
  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);
  }
  /**
   * Allows the validation decorator to write markup after the field has written all of its markup.
   * In addition, may invoke the <code>core/fields:showValidationError</code> function to present
   * the field's error (if it has one) to the user.
   */
  @AfterRender
  final void afterDecorator() {
    decorator.afterField(this);

    String error = validationTracker.getError(this);

    if (error != null) {
      javaScriptSupport
          .require("t5/core/fields")
          .invoke("showValidationError")
          .with(assignedClientId, error);
    }
  }
 /**
  * Invoked from subclasses after they have written their tag and (where appropriate) their
  * informal parameters <em>and</em> have allowed their {@link Validator} to write markup as well.
  */
 protected final void decorateInsideField() {
   decorator.insideField(this);
 }
 /** Allows the validation decorator to write markup before the field itself writes markup. */
 @BeginRender
 final void beforeDecorator() {
   decorator.beforeField(this);
 }