@Override
 protected void onComponentTag(ComponentTag tag) {
   checkComponentTag(tag, "progress");
   super.onComponentTag(tag);
   tag.put("value", value.get());
   tag.put("max", max.get());
 }
 public static void addAttribute(ComponentTag tag, String attName, String addValue, String sep) {
   String value = tag.getAttributes().getString(attName);
   if (StringUtils.isEmpty(value)) {
     tag.put(attName, addValue);
   } else {
     tag.put(attName, value + sep + addValue);
   }
 }
Пример #3
0
 @Override
 public void onComponentTag(ComponentTag tag) {
   // add onclick handler to the browser
   // if clicked in the browser, the function
   // click.response(AjaxRequestTarget target) is called on the server side
   tag.put("ondblclick", "Wicket.Ajax.get({'u':'" + click.getCallbackUrl() + "'})");
   tag.put("onclick", "Wicket.Ajax.get({'u':'" + click.getCallbackUrl() + "'})");
 }
    /** {@inheritDoc} */
    @Override
    protected void onComponentTag(ComponentTag tag) {
      super.onComponentTag(tag);

      if (!isValid()) {
        tag.put("class", "imxt-invalid");
        FeedbackMessage message = getFeedbackMessages().first();
        if (message != null) {
          tag.put("title", message.getMessage().toString());
        }
      }
    }
 @Override
 public void onComponentTag(Component component, ComponentTag tag) {
   FormComponent<?> f = (FormComponent<?>) component;
   if (!f.isValid()) {
     String cl = tag.getAttribute("class");
     if (cl == null) {
       tag.put("class", "error");
     } else {
       tag.put("class", "error " + cl);
     }
   }
 }
Пример #6
0
  /*
   * (non-Javadoc)
   *
   * @see org.apache.wicket.behavior.Behavior#onComponentTag(org.apache.wicket.Component,
   * org.apache.wicket.markup.ComponentTag)
   */
  @Override
  public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);

    if (!Form.class.isAssignableFrom(component.getClass())) {
      throw new WicketRuntimeException("This behavior is only applicable on a Form component");
    }

    Form<?> form = (Form<?>) component;

    // Retrieve and set form name
    String formName = verifyFormName(form, tag);

    tag.put("onsubmit", "return yav.performCheck('" + formName + "', rules);");

    // Open the Yav script (inlined JavaScript)
    AppendingStringBuffer buffer = new AppendingStringBuffer("<script>\n");
    buffer.append("var rules=new Array();\n");

    // Visit all form components and check for validators (and write the
    // appropriate Yav rules in the current inlined JavaScript)
    form.visitFormComponents(new YavFormComponentVisitor(buffer, form));

    // Build the call to the yav.init with the proper form name
    buffer.append("function yavInit() {\n");
    buffer.append("    yav.init('" + formName + "', rules);\n");
    buffer.append("}\n");

    // Close the Yav script
    buffer.append("</script>\n");

    // Write the generated script into the response
    Response response = RequestCycle.get().getResponse();
    response.write(buffer.toString());
  }
 @Override
 protected void onComponentTag(ComponentTag tag) {
   if (style != null && !"null".equals(style)) {
     tag.put("style", style);
   }
   super.onComponentTag(tag);
 }
Пример #8
0
  /** @see Component#onComponentTag(ComponentTag) */
  @Override
  protected void onComponentTag(final ComponentTag tag) {

    tag.put("value", getDefaultModelObjectAsString());

    super.onComponentTag(tag);
  }
    @Override
    public void onComponentTag(final Component component, final ComponentTag tag) {
      String expr = tag.getAttributes().getString(wicketMessageAttrName);
      if (!Strings.isEmpty(expr)) {
        expr = expr.trim();

        String[] attrsAndKeys = Strings.split(expr, ',');

        for (String attrAndKey : attrsAndKeys) {
          int colon = attrAndKey.lastIndexOf(":");
          // make sure the attribute-key pair is valid
          if (attrAndKey.length() < 3 || colon < 1 || colon > attrAndKey.length() - 2) {
            throw new WicketRuntimeException(
                "wicket:message attribute contains an invalid value [["
                    + expr
                    + "]], must be of form (attr:key)+");
          }

          String attr = attrAndKey.substring(0, colon);
          String key = attrAndKey.substring(colon + 1);

          // we need to call the proper getString() method based on
          // whether or not we have a default value
          final String value;
          if (tag.getAttributes().containsKey(attr)) {
            value = component.getString(key, null, tag.getAttributes().getString(attr));
          } else {
            value = component.getString(key);
          }
          tag.put(attr, value);
        }
      }
    }
Пример #10
0
  /**
   * Adds random noise to the url every request to prevent the browser from caching the image.
   *
   * @param tag
   */
  protected final void addAntiCacheParameter(final ComponentTag tag) {
    String url = tag.getAttributes().getString("src");
    url = url + (url.contains("?") ? "&" : "?");
    url = url + "antiCache=" + System.currentTimeMillis();

    tag.put("src", url);
  }
Пример #11
0
  /** @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag) */
  @Override
  protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    checkComponentTag(tag, "label");

    LabeledWebMarkupContainer formComponent = getFormComponent();

    tag.put("for", formComponent.getMarkupId());

    if (formComponent instanceof FormComponent<?>) {
      FormComponent<?> fc = (FormComponent<?>) formComponent;

      if (fc.isRequired()) {
        tag.append("class", getString(REQUIRED_CSS_CLASS_KEY), " ");
      }
      if (fc.isValid() == false) {
        tag.append("class", getString(INVALID_CSS_CLASS_KEY), " ");
      }
    }

    if (formComponent.isEnabledInHierarchy() == false) {
      tag.append("class", getString(DISABLED_CSS_CLASS_KEY), " ");
    }

    // always transform the tag to <span></span> so even labels defined as <span/> render
    tag.setType(TagType.OPEN);
  }
Пример #12
0
  @Override
  protected void onComponentTag(ComponentTag tag) {
    // WICKET-5594 prevent non-Ajax submit
    tag.put("type", "button");

    super.onComponentTag(tag);
  }
Пример #13
0
 /**
  * @param form
  * @param tag
  * @return
  */
 private String verifyFormName(Form<?> form, ComponentTag tag) {
   IValueMap attributes = tag.getAttributes();
   String value = attributes.getString("name");
   if (value == null) {
     value = form.getId();
     tag.put("name", value);
   }
   return value;
 }
Пример #14
0
  /**
   * Processes the component tag.
   *
   * @param tag Tag to modify
   * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
   */
  @Override
  protected void onComponentTag(final ComponentTag tag) {
    checkComponentTag(tag, "input");
    checkComponentTagAttribute(tag, "type", "checkbox");

    final String value = getValue();
    final IConverter<Boolean> converter = getConverter(Boolean.class);
    final Boolean checked = converter.convertToObject(value, getLocale());

    if (Boolean.TRUE.equals(checked)) {
      tag.put("checked", "checked");
    } else {
      // In case the attribute was added at design time
      tag.remove("checked");
    }

    // remove value attribute, because it overrides the browser's submitted value, eg a [input
    // type="checkbox" value=""] will always submit as false
    tag.remove("value");

    // Should a roundtrip be made (have onSelectionChanged called) when the
    // checkbox is clicked?
    if (wantOnSelectionChangedNotifications()) {
      CharSequence url = urlForListener(new PageParameters());

      Form<?> form = findParent(Form.class);
      if (form != null) {
        tag.put("onclick", form.getJsForInterfaceUrl(url));
      } else {
        // NOTE: do not encode the url as that would give invalid
        // JavaScript
        tag.put(
            "onclick",
            "window.location.href='"
                + url
                + (url.toString().indexOf('?') > -1 ? "&" : "?")
                + getInputName()
                + "=' + this.checked;");
      }
    }

    super.onComponentTag(tag);
  }
  @Override
  protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    if (isLinkEnabled()) {
      if (tag.getName().toLowerCase().equals("a")) {
        tag.put("href", "#");
      }
    } else {
      disableLink(tag);
    }
  }
 @Override
 public void onComponentTag(Component component, ComponentTag tag) {
   FormComponent<?> fc = (FormComponent<?>) component;
   if (fc.isRequired() && fc.isEnabled()) {
     //
     // http://dev.w3.org/html5/spec/single-page.html#attr-input-required
     //
     // this produces a browser message before Wicket can do a 'required'
     // error message; the browser feedback does not necessarily match
     // the bootstrap error layout, but is given without a roundtrip.
     //
     tag.put("required", "required");
   }
 }
  @Override
  protected void onComponentTag(final ComponentTag tag) {
    super.onComponentTag(tag);

    tag.put("autocomplete", "off"); // disable browser's autocomplete
  }
 @Override
 public void onComponentTag(Component component, ComponentTag tag) {
   tag.put("onmouseup", "this.innerHTML = '" + _content + "'");
 }
Пример #19
0
 @Override
 protected void onComponentTag(ComponentTag tag) {
   super.onComponentTag(tag);
   tag.put("class", cssClass + " col-sm-" + size);
 }
Пример #20
0
 /**
  * {@inheritDoc}
  *
  * @see org.apache.wicket.behavior.AbstractBehavior#onComponentTag(org.apache.wicket.Component,
  *     org.apache.wicket.markup.ComponentTag)
  */
 @Override
 public void onComponentTag(Component component, ComponentTag tag) {
   super.onComponentTag(component, tag);
   tag.put("rel", JQ_COMPONENT_NAME);
 }
Пример #21
0
 protected void onComponentTag(ComponentTag tag) {
   super.onComponentTag(tag);
   tag.put("class", (getIndex() % 2 == 0) ? this.oddClass : this.evenClass);
 }
Пример #22
0
 /** {@inheritDoc} */
 @Override
 public void onComponentTag(Component component, ComponentTag tag) {
   Map<String, String> vars = new MicroMap<String, String>("page", String.valueOf(page + 1));
   tag.put("title", PagingNavigation.this.getString(RES, Model.ofMap(vars)));
 }