Пример #1
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
  public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);

    IValueMap attributes = tag.getAttributes();
    attributes.put("data-header-selector", "#" + header.getMarkupId());
    attributes.put("data-footer-selector", "#" + footer.getMarkupId());
  }
Пример #3
0
  @Override
  public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);

    Components.assertTag(component, tag, "code", "pre");
  }
Пример #4
0
 /** {@inheritDoc} */
 @Override
 public void onComponentTag(final Component aComponent, final ComponentTag aTag) {
   for (final Behavior behavior : behaviors_) behavior.onComponentTag(aComponent, aTag);
 }