/**
   * {@inheritDoc} <br>
   * Also, {@link #onConfigure(Component)} will call {@link
   * IJQueryWidget#onConfigure(JQueryBehavior)} (if the component IS-A {@link IJQueryWidget})<br>
   * If a property is set in {@link #onConfigure(Component)} and is needed in {@link
   * IJQueryWidget#onConfigure(JQueryBehavior)}, {@code super.onConfigure(component)} should be the
   * last statement.
   */
  @Override
  public void onConfigure(Component component) {
    super.onConfigure(component);

    if (component instanceof IJQueryWidget) {
      ((IJQueryWidget) component).onConfigure(this);
    }
  }
  /**
   * {@inheritDoc} <br>
   * Also, {@link #beforeRender(Component)} will call {@link
   * IJQueryWidget#onBeforeRender(JQueryBehavior)} (if the component IS-A {@link IJQueryWidget})<br>
   * If a property is set in {@link #beforeRender(Component)} and is needed in {@link
   * IJQueryWidget#onBeforeRender(JQueryBehavior)}, {@code super.beforeRender(component)} should be
   * the last statement.
   */
  @Override
  public void beforeRender(Component component) {
    super.beforeRender(component);

    if (component instanceof IJQueryWidget) {
      ((IJQueryWidget) component).onBeforeRender(this);
    }
  }
  @Override
  public void bind(Component component) {
    super.bind(component);

    if (this.component != null) {
      throw new WicketRuntimeException("Behavior is already bound to another component.");
    }

    this.component = component;
    this.component.add(AttributeModifier.append("class", INVOKER_CSS_CLASS));
    this.component.add(this.onContextMenuEventBehavior = this.newOnContextMenuBehavior());
  }
  @Override
  public void renderHead(Component component, IHeaderResponse response) {
    super.renderHead(component, response);

    // renders javascript events
    if (this.events != null) {
      StringBuilder statements = new StringBuilder();

      for (String event : this.events) {
        statements.append(event);
      }

      this.renderOnDomReadyScript(statements.toString(), response);
    }
  }