public boolean setupRender(FrameworkMixin mixin, MarkupWriter writer) {
    if (!instrument(mixin)) {
      return false;
    }
    String componentName =
        mixin.getComponentResources().getContainer().getClass().getCanonicalName();
    String fw = mixin.getFW();

    mixin.setRoot(writer.elementNS(fw, fw + ".mixin"));
    writer.attributes(fw + ".type", mixin.getType());
    writer.attributes(fw + ".component", componentName);
    return bootstrapProvider.setupRender(mixin, writer);
  }
  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();
  }
    void write(MarkupWriter writer) {
      Object value = binding.get();

      if (value == null) return;

      if (value instanceof Block) return;

      // If it's already a String, don't use the TypeCoercer (renderInformalParameters is
      // a CPU hotspot, as is TypeCoercer.coerce).

      String valueString =
          value instanceof String ? (String) value : elementResources.coerce(value, String.class);

      writer.attributes(name, valueString);
    }
Esempio n. 4
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();
  }
Esempio n. 5
0
 void beginRender(MarkupWriter writer) {
   writer.attributes("data-confirm-title", title, "data-confirm-message", message);
 }
Esempio n. 6
0
  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);
  }