Exemplo n.º 1
0
  final void afterRender(MarkupWriter writer) {
    // TextArea will not have a template.

    if (value != null) writer.write(value);

    writer.end(); // textarea
  }
Exemplo n.º 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);
  }
Exemplo n.º 3
0
  protected void generateResponseMarkup(MarkupWriter writer, List matches) {
    writer.element("ul");

    for (Object o : matches) {
      Employee employee = (Employee) o;
      writer.element("li");
      writer.attributes("id", employee.getId());
      writer.write(employee.getFirstName() + " " + employee.getLastName());
      writer.end();
    }

    writer.end();
  }
Exemplo n.º 4
0
  boolean beginRender(MarkupWriter writer) {
    clientId = javaScriptSupport.allocateClientId(resources);

    if (storage != null) {
      List<Alert> alerts = storage.getAlerts();
      if (!alerts.isEmpty()) {
        for (Alert alert : alerts) {

          String alertType = alert.severity.name().toLowerCase();
          String css = alertType;
          if ("info".equals(alertType)) {
            css = "success";
          }
          css = "alert-" + css;

          writer.element("div", "id", clientId, "class", "alert " + css);
          {
            resources.renderInformalParameters(writer);

            String dismiss = resources.createEventLink("dismiss", alert.id).toURI();
            if (alert.duration.persistent) {
              writer.element("a", "href", dismiss, "class", "close");

            } else {
              writer.element("a", "href", "#", "class", "close", "data-dismiss", "alert");
            }
            writer.write(dismissText);
            writer.end();

            writer.write(alert.message);
          }
          writer.end();
        }
      }
      storage.dismissNonPersistent();
    }

    return false;
  }
Exemplo n.º 5
0
  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();
  }
Exemplo n.º 6
0
  /** 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);
  }
Exemplo n.º 7
0
 void beginRender(MarkupWriter writer) {
   if (value != null) writer.write(getFormatedValue());
 }