Example usage for org.apache.wicket Page getBehaviors

List of usage examples for org.apache.wicket Page getBehaviors

Introduction

In this page you can find the example usage for org.apache.wicket Page getBehaviors.

Prototype

public final List<? extends Behavior> getBehaviors() 

Source Link

Document

Gets the currently coupled Behavior s as a unmodifiable list.

Usage

From source file:org.hippoecm.frontend.behaviors.OnEnterAjaxBehavior.java

License:Apache License

/**
 * Don't call super since WicketAjax is loaded by Yui webapp behavior
 * TODO: webapp ajax is configurable, maybe check here and still load it.
 *///from   w  w  w  .j av a2  s.  c  o m
@Override
public final void renderHead(Component component, IHeaderResponse response) {
    super.renderHead(component, response);

    if (_helper == null) {
        Page page = component.getPage();
        for (Behavior behavior : page.getBehaviors()) {
            if (behavior instanceof IYuiManager) {
                _helper = ((IYuiManager) behavior).newContext();
                _helper.addJavascriptReference(
                        new JavaScriptResourceReference(OnEnterAjaxBehavior.class, "enter.js"));
                break;
            }
        }
        if (_helper == null) {
            throw new IllegalStateException(
                    "Page has no yui manager behavior, unable to register module dependencies.");
        }
        _helper.addOnDomLoad("new Hippo.EnterHandler('" + component.getMarkupId() + "')");
    }
    _helper.renderHead(response);
}

From source file:org.hippoecm.frontend.plugins.yui.AbstractYuiAjaxBehavior.java

License:Apache License

/**
 * Don't call super since WicketAjax is loaded by Yui webapp behavior 
 * TODO: webapp ajax is configurable, maybe check here and still load it.
 *//*from   w  ww .j  a  v a2  s.c o m*/
@Override
public void renderHead(Component component, IHeaderResponse response) {
    if (context == null) {
        Page page = component.getPage();
        for (Behavior behavior : page.getBehaviors()) {
            if (behavior instanceof IYuiManager) {
                context = ((IYuiManager) behavior).newContext();
                addHeaderContribution(context);
                break;
            }
        }
        if (context == null) {
            throw new IllegalStateException(
                    "Page has no yui manager behavior, unable to register module dependencies.");
        }
    }
    onRenderHead(response);
    context.renderHead(response);
}

From source file:org.hippoecm.frontend.plugins.yui.AbstractYuiBehavior.java

License:Apache License

/**
 * Don't call super since WicketAjax is loaded by Yui webapp behavior
 * TODO: webapp ajax is configurable, maybe check here and still load it.
 *//* w ww.j  ava2s  . c o  m*/
@Override
public final void renderHead(Component component, IHeaderResponse response) {
    if (context == null) {
        Page page = component.getPage();
        for (Behavior behavior : page.getBehaviors()) {
            if (behavior instanceof IYuiManager) {
                context = ((IYuiManager) behavior).newContext();
                addHeaderContribution(context);
                break;
            }
        }
        if (context == null) {
            throw new IllegalStateException(
                    "Page has no yui manager behavior, unable to register module dependencies.");
        }
    }
    context.renderHead(response);
    onRenderHead(response);
}