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

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

    writer.end(); // textarea
  }
Esempio n. 2
0
 @AfterRender
 void afterRender(MarkupWriter writer) {
   value = temp;
   writer.element("div", "id", field.getClientId() + "_after_but_before");
   writer.writeRaw(value + "-after");
   writer.end();
 }
Esempio n. 3
0
 @BeginRender
 void beginRender(MarkupWriter writer) {
   writer.element("div", "id", field.getClientId() + "_before_but_after");
   writer.writeRaw(value + "-before");
   writer.end();
   temp = value;
   value = "beginrender_for_mixinafter_isreally_justafter_corecomponent_render";
 }
Esempio n. 4
0
 @BeginRender
 void beginRender(MarkupWriter writer) {
   if (checked) {
     writer.element("input", "type", "checkbox", "checked", "checked");
   } else {
     writer.element("input", "type", "checkbox");
   }
   resources.renderInformalParameters(writer);
   writer.end();
 }
Esempio n. 5
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);
  }
  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);
  }
Esempio n. 7
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;
  }
  /**
   * 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();
    }
  }
Esempio n. 9
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);
  }
Esempio n. 10
0
  @AfterRender
  public void afterRender(MarkupWriter writer) {
    writer.end();

    String id = field.getClientId();

    if (options == null) options = new JSONObject();
    JSONObject opt = new JSONObject();
    opt.put("id", id);
    opt.put("params", options);

    javaScriptSupport.require("kawwa/productquantity").with(opt);
  }
Esempio n. 11
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();
  }
    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. 13
0
  @Override
  protected final void writeFieldTag(MarkupWriter writer, String value) {
    writer.element(
        "textarea",
        "name",
        getControlName(),
        "class",
        cssClass,
        "id",
        getClientId(),
        "cols",
        getWidth());

    // Save until needed in after()

    this.value = value;
  }
Esempio n. 14
0
  /**
   * 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());
    }
  }
  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();
  }
Esempio n. 16
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;
  }
Esempio n. 17
0
  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);
    }
  }
Esempio n. 18
0
  void beginRender(MarkupWriter writer) {

    String clientId = getClientId();

    writer.element("table", "id", clientId);
    writer.end();
    writer.element("div", "id", "pager" + clientId);
    writer.end();

    JSONObject setup = new JSONObject();
    setup.put("field", clientId);

    /*url:'server.php?q=2',
    datatype: "json",*/

    JSONObject jqgridParams = new JSONObject();
    jqgridParams.put("url", resources.createEventLink("data").toAbsoluteURI());
    jqgridParams.put("datatype", "json");

    // colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
    JSONArray colNames = new JSONArray();
    List<String> names = getDataModel().getPropertyNames();
    for (String name : names) colNames.put(name);
    jqgridParams.put("colNames", colNames);

    /*colModel:[
    	{name:'id',index:'id', width:55},
    	{name:'invdate',index:'invdate', width:90},
    	{name:'name',index:'name', width:100},
    	{name:'amount',index:'amount', width:80, align:"right"},
    	{name:'tax',index:'tax', width:80, align:"right"},
    	{name:'total',index:'total', width:80,align:"right"},
    	{name:'note',index:'note', width:150, sortable:false}
    ],*/

    JSONArray colModel = new JSONArray();
    for (String name : names) {
      JSONObject model = new JSONObject();
      model.put("name", name);

      model.put("index", name);
      model.put("width", 100);
      colModel.put(model);
      // is this column sorted?
      if (sortAscending != null) {
        ColumnSort colSort = getSortModel().getColumnSort(name);
        if (colSort != ColumnSort.UNSORTED) {
          // sortname: 'id',
          jqgridParams.put("sortname", name);
          // sortorder: "desc",
          if (colSort == ColumnSort.ASCENDING) jqgridParams.put("sortorder", "asc");
          else jqgridParams.put("sortorder", "dsc");
        }
      }
    }
    jqgridParams.put("colModel", colModel);

    // rowNum:10,
    jqgridParams.put("rowNum", rowsPerPage);

    // rowList:[10,20,30],

    // pager: '#pager5',
    jqgridParams.put("pager", "#pager" + clientId);

    // viewrecords: true,

    // caption:"Simple data manipulation",
    jqgridParams.put("caption", "Simple data manipulation");

    // editurl:"someurl.php"
    jqgridParams.put("editurl", resources.createEventLink("edit").toAbsoluteURI());

    jqgridParams
        .put("sortable", true)
        .put("viewrecords", true)
        .put("rowList", new JSONLiteral("[5,10,15]"));

    JQueryUtils.merge(jqgridParams, additionalParams);

    setup.put("params", jqgridParams);

    if (request.getAttribute(LOCALIZATION_CONFIGURED_FLAG) == null) {
      JSONObject spec = new JSONObject();
      request.setAttribute(LOCALIZATION_CONFIGURED_FLAG, true);
    }

    support.addInitializerCall("jqGrid", setup);
  }
Esempio n. 19
0
 @SetupRender
 public void setupRender(MarkupWriter writer) {
   writer.element("p", "class", "k-quantity");
 }
Esempio n. 20
0
 void beginRender(MarkupWriter writer) {
   writer.attributes("data-confirm-title", title, "data-confirm-message", message);
 }
Esempio n. 21
0
 @BeginRender
 public void beginRender(MarkupWriter writer) {
   writer.getElement().addClassName("uppydowner");
 }
Esempio n. 22
0
 @BeginRender
 void beginRender(MarkupWriter writer) {
   if (tags == null) {
     return;
   }
   if (tags.getTitle() != null) {
     writer.element("meta", "property", "og:title", "content", tags.getTitle());
     writer.end();
   }
   if (tags.getType() != null) {
     writer.element("meta", "property", "og:type", "content", tags.getType());
     writer.end();
   }
   if (tags.getImageURL() != null) {
     writer.element("meta", "property", "og:image", "content", tags.getImageURL());
     writer.end();
   }
   if (tags.getUrl() != null) {
     writer.element("meta", "property", "og:url", "content", tags.getUrl());
     writer.end();
   }
   if (tags.getSiteName() != null) {
     writer.element("meta", "property", "og:site_name", "content", tags.getSiteName());
     writer.end();
   }
   if (tags.getApplicationID() != null) {
     writer.element("meta", "property", "fb:app_id", "content", tags.getApplicationID());
     writer.end();
   }
   if (tags.getAdmins() != null) {
     writer.element("meta", "property", "fb:admins", "content", tags.getAdmins());
     writer.end();
   }
 }
 public boolean cleanupRender(FrameworkMixin mixin, MarkupWriter writer) {
   if (mixin.getRoot() != null) {
     writer.end();
   }
   return bootstrapProvider.cleanupRender(mixin, writer);
 }
Esempio n. 24
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);
  }
 private void addErrorClassToCurrentElement() {
   markupWriter.getElement().addClassName(CSSClassConstants.ERROR);
 }
Esempio n. 26
0
 public void afterRender(MarkupWriter writer) {
   writer.end();
 }
Esempio n. 27
0
 void beginRender(MarkupWriter writer) {
   if (value != null) writer.write(getFormatedValue());
 }
Esempio n. 28
0
 /**
  * Tapestry render phase method. End a tag here.
  *
  * @param writer the markup writer
  */
 void afterRender(MarkupWriter writer) {
   Element element = writer.getDocument().getElementById(clientElement.getClientId());
   javascriptSupport.addScript(
       "Nifty('%s#%s','%s');", element.getName(), clientElement.getClientId(), options);
 }
Esempio n. 29
0
 public void render(MarkupWriter writer, RenderQueue queue) {
   writer.end();
 }
  @AfterRender
  public void afterRender(MarkupWriter writer) {
    String id;
    if (elementName == null) {
      elementName = resources.getElementName();
      if (elementName == null) {
        elementName = "ul";
      }
    }
    if (draggableName == null) {
      draggableName = "div";
      if (elementName.equals("ul")) {
        draggableName = "li";
      }
    }

    Object compoment = resources.getContainer();
    if (ClientElement.class.isAssignableFrom(compoment.getClass())) {
      id = ((ClientElement) compoment).getClientId();
    } else {
      id = javaScriptSupport.allocateClientId(resources);
    }
    if (Grid.class.isAssignableFrom(compoment.getClass())) {
      elementName = "tbody";
      draggableName = "tr";
    }

    element = writer.getElement();

    element.visit(
        new Visitor() {

          public void visit(Element e) {
            if (e.getName().equals(elementName)) {
              element = e;
            }
            if (e.getName().equals("tr")) {
              String c = e.getAttribute("class");
              if (c != null) {
                e.forceAttributes("id", c.split(" ")[0]);
              }
            }
          }
        });
    String currentID = element.getAttribute("id");
    if (currentID != null) {
      id = currentID;
    } else {
      element.forceAttributes("id", id);
    }
    // element.addClassName("sortable");
    // logger.info("spec {}",spec);
    if (!spec.has("selector")) {
      spec.put("selector", String.format("#%s %s", id, draggableName));
    }
    if (!spec.has("context")) {
      ArrayEventContext aec = new ArrayEventContext(typeCoercer, defaulted(context));
      spec.put("context", String.format("/%s", contextPathEncoder.encodeIntoPath(aec)));
    }
    javaScriptSupport.addInitializerCall("jqDraggable", spec);
  }