コード例 #1
0
  @Override
  public void bind(final Component component) {
    super.bind(component);

    BootstrapBaseBehavior.addTo(component);
    component.add(cssClassNameAppender);
  }
コード例 #2
0
  @Override
  public void unbind(final Component component) {
    super.unbind(component);

    BootstrapBaseBehavior.removeFrom(component);
    component.remove(cssClassNameAppender);
  }
コード例 #3
0
ファイル: YavBehavior.java プロジェクト: raduf/core
  /*
   * (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());
  }
コード例 #4
0
  @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());
  }
コード例 #5
0
  @Override
  public void detach(Component component) {
    super.detach(component);

    lineNumbers.detach();
    cssClassNameModel.detach();
    language.detach();
    from.detach();
  }
コード例 #6
0
  @Override
  public void onConfigure(Component component) {
    super.onConfigure(component);

    if (hasBeenRendered == false) {
      hasBeenRendered = true;

      form.visitChildren(FormComponent.class, new FormValidateVisitor());
    }
  }
コード例 #7
0
  /**
   * Invokes a given interface on a component's behavior.
   *
   * @param rcomponent The component
   * @param behavior
   * @throws ListenerInvocationNotAllowedException when listener invocation attempted on a component
   *     that does not allow it
   */
  public final void invoke(final IRequestableComponent rcomponent, final Behavior behavior) {
    // we are in Wicket core land
    final Component component = (Component) rcomponent;

    if (!behavior.canCallListenerInterface(component)) {
      log.warn(
          "behavior not enabled; ignore call. Behavior {} at component {}", behavior, component);
      throw new ListenerInvocationNotAllowedException(
          component, behavior, "Behavior rejected interface invocation. ");
    }

    internalInvoke(component, behavior);
  }
コード例 #8
0
  @Override
  public void renderHead(final Component component, final IHeaderResponse response) {
    super.renderHead(component, response);

    response.render(CssHeaderItem.forReference(BootstrapPrettifyCssReference.INSTANCE));

    References.renderWithFilter(
        Bootstrap.getSettings(),
        response,
        JavaScriptHeaderItem.forReference(BootstrapPrettifyJavaScriptReference.INSTANCE));

    response.render(
        OnDomReadyHeaderItem.forScript(createInitializerScript(component.getMarkupId(true))));
  }
コード例 #9
0
  @Override
  public void bind(Component component) {
    super.bind(component);

    if (component instanceof Form<?>) {
      form = (Form<?>) component;
    } else {
      form = Form.findForm(component);
      if (form == null) {
        throw new WicketRuntimeException(
            AjaxFormValidatingBehavior.class.getSimpleName()
                + " should be bound to a Form component or a component that is inside a form!");
      }
    }
  }
コード例 #10
0
ファイル: YavBehavior.java プロジェクト: raduf/core
  /*
   * (non-Javadoc)
   *
   * @see org.apache.wicket.behavior.AbstractBehavior#renderHead(org.apache.wicket
   * .markup.html.IHeaderResponse)
   */
  @Override
  public void renderHead(Component c, IHeaderResponse response) {
    super.renderHead(c, response);

    response.render(
        CssHeaderItem.forReference(
            new PackageResourceReference(YavBehavior.class, "style/yav-style.css")));

    addJavascriptReference(response, "yav.js");
    addJavascriptReference(response, "yav-config.js");
    addJavascriptReference(response, "util.js");

    // Add an onload contributor that will call a function which is defined
    // during onComponentTag method call which is processed after the head
    // is rendered (warning, not compliant with XHTML 1.0 Strict DTD)
    response.render(OnLoadHeaderItem.forScript("yavInit()"));
  }
コード例 #11
0
  @Override
  public void bind(Component component) {
    super.bind(component);
    component.add(
        new CssClassAppender(
            new CssClassToggleModel(BootstrapCssClass.FORM_HORIZONTAL) {

              @Override
              protected boolean isActive() {
                return FormStyleBehavior.this.isHorizontal();
              }
            }));
    component.add(
        new CssClassAppender(
            new CssClassToggleModel(BootstrapCssClass.FORM_INLINE) {

              @Override
              protected boolean isActive() {
                return FormStyleBehavior.this.isInline();
              }
            }));
  }
コード例 #12
0
  @Override
  public void bind(final Component component) {
    super.bind(component);
    this.component = component;
    this.component.setOutputMarkupId(true);
    if (addTitle && !isAjax())
      component.add(
          new AttributeModifier("title", true, new Model<String>(title + "::" + content)));
    if (isAjax()) {
      this.component.add(new MootipAjaxListener(panel));
      component.add(
          new AttributeModifier(
              "title",
              true,
              new Model<String>("CALLBACK:mootipAjax" + getEscapedComponentMarkupId() + "()")));
    }

    component.add(
        new AttributeModifier(
            "class", true, new Model<String>("toolTipImg" + getEscapedComponentMarkupId())));

    component.setOutputMarkupId(true);
  }
コード例 #13
0
  @Override
  public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);

    Components.assertTag(component, tag, "code", "pre");
  }
コード例 #14
0
  /** {@inheritDoc} */
  @Override
  public void onConfigure(final Component component) {
    super.onConfigure(component);

    cssClassNameModel.setObject(createCssClassNames());
  }
コード例 #15
0
 @Override
 public void bind(Component component) {
   super.bind(component);
   this.component = component;
   component.add(getResourcePackage());
 }
コード例 #16
0
 @Override
 public void beforeRender(Component component) {
   super.beforeRender(component);
   templateStrategy.load(this);
   write(templateStrategy.getBeforeRenderString());
 }
コード例 #17
0
 @Override
 public void afterRender(Component component) {
   super.afterRender(component);
   write(templateStrategy.getAfterRenderString());
 }
コード例 #18
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public void afterRender(final Component arg0) {
   for (final Behavior behavior : behaviors_) behavior.afterRender(arg0);
 }
コード例 #19
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public boolean isTemporary(final Component component) {
   boolean back = true;
   for (final Behavior behavior : behaviors_) back = back && behavior.isTemporary(component);
   return back;
 }
コード例 #20
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 @Override
 public boolean isEnabled(final Component arg0) {
   boolean back = true;
   for (final Behavior behavior : behaviors_) back = back && behavior.isEnabled(arg0);
   return back;
 }
コード例 #21
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public boolean getStatelessHint(final Component arg0) {
   boolean back = true;
   for (final Behavior behavior : behaviors_) back = back && behavior.getStatelessHint(arg0);
   return back;
 }
コード例 #22
0
 @Override
 public void renderHead(Component component, IHeaderResponse response) {
   super.renderHead(component, response);
   response.render(JavaScriptHeaderItem.forReference(INSTANCE));
 }
コード例 #23
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public void detach(final Component arg0) {
   for (final Behavior behavior : behaviors_) behavior.detach(arg0);
 }
コード例 #24
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public void bind(final Component arg0) {
   for (final Behavior behavior : behaviors_) behavior.bind(arg0);
 }
コード例 #25
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public void beforeRender(final Component arg0) {
   for (final Behavior behavior : behaviors_) behavior.beforeRender(arg0);
 }
コード例 #26
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public void onComponentTag(final Component aComponent, final ComponentTag aTag) {
   for (final Behavior behavior : behaviors_) behavior.onComponentTag(aComponent, aTag);
 }
コード例 #27
0
 @Override
 public void renderHead(Component component, IHeaderResponse headerResponse) {
   super.renderHead(component, headerResponse);
   headerResponse.renderOnLoadJavaScript(
       "document.getElementById('" + component.getMarkupId() + "').focus();");
 }
コード例 #28
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 public void exception(final Component component, final RuntimeException aException) {
   for (final Behavior behavior : behaviors_) behavior.onException(component, aException);
 }
コード例 #29
0
ファイル: CompositeBehavior.java プロジェクト: russpitre/core
 /** {@inheritDoc} */
 @Override
 public void renderHead(final Component component, final IHeaderResponse response) {
   super.renderHead(component, response);
   for (final Behavior behavior : behaviors_) behavior.renderHead(component, response);
 }