Search in sources :

Example 1 with OnDomReadyHeaderItem

use of org.apache.wicket.markup.head.OnDomReadyHeaderItem in project ocvn by devgateway.

the class JavascriptCallbackAjaxBehavior method renderHead.

@Override
public void renderHead(final Component component, final IHeaderResponse response) {
    Map<String, Object> map = new HashMap<>();
    map.put("callbackUrl", getCallbackUrl().toString());
    map.put("args", getCallbackArguments());
    map.put("componentMarkupId", component.getMarkupId());
    try {
        if (scriptTemplate != null) {
            OnDomReadyHeaderItem onDomReadyHeaderItem = OnDomReadyHeaderItem.forScript(scriptTemplate.asString(map));
            scriptTemplate.close();
            response.render(onDomReadyHeaderItem);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : OnDomReadyHeaderItem(org.apache.wicket.markup.head.OnDomReadyHeaderItem) HashMap(java.util.HashMap)

Example 2 with OnDomReadyHeaderItem

use of org.apache.wicket.markup.head.OnDomReadyHeaderItem in project webanno by webanno.

the class UrlParametersReceivingBehavior method renderHead.

@Override
public void renderHead(Component component, IHeaderResponse response) {
    super.renderHead(component, response);
    StringBuilder sb = new StringBuilder().append("try{").append("window.UrlUtil = newUrlUtil(").append(optionsJsonString()).append(");").append("UrlUtil.setWicketAjaxCall(function(){" + getCallbackFunctionBody() + "});").append("$(window).bind('hashchange',window.UrlUtil.back);").append("window.UrlUtil.sendUrlParameters();").append("}catch(e){}");
    response.render(new OnDomReadyHeaderItem(sb.toString()));
    response.render(getJS(UrlFragment.class));
}
Also used : OnDomReadyHeaderItem(org.apache.wicket.markup.head.OnDomReadyHeaderItem) UrlFragment(org.wicketstuff.urlfragment.UrlFragment)

Example 3 with OnDomReadyHeaderItem

use of org.apache.wicket.markup.head.OnDomReadyHeaderItem in project wicket by apache.

the class AbstractAutoCompleteBehavior method renderAutocompleteHead.

/**
 * Render autocomplete init javascript and other head contributions
 *
 * @param response
 */
private void renderAutocompleteHead(final IHeaderResponse response) {
    response.render(JavaScriptHeaderItem.forReference(AUTOCOMPLETE_JS));
    String initJS = String.format("new Wicket.AutoComplete(%s, %s);", renderAjaxAttributes(getComponent()), constructSettingsJS());
    final OnDomReadyHeaderItem onDomReady = OnDomReadyHeaderItem.forScript(initJS);
    response.render(new WrappedHeaderItem(onDomReady));
}
Also used : OnDomReadyHeaderItem(org.apache.wicket.markup.head.OnDomReadyHeaderItem) IWrappedHeaderItem(org.apache.wicket.markup.head.IWrappedHeaderItem)

Example 4 with OnDomReadyHeaderItem

use of org.apache.wicket.markup.head.OnDomReadyHeaderItem in project oc-explorer by devgateway.

the class JavascriptCallbackAjaxBehavior method renderHead.

@Override
public void renderHead(final Component component, final IHeaderResponse response) {
    Map<String, Object> map = new HashMap<>();
    map.put("callbackUrl", getCallbackUrl().toString());
    map.put("args", getCallbackArguments());
    map.put("componentMarkupId", component.getMarkupId());
    try {
        if (scriptTemplate != null) {
            OnDomReadyHeaderItem onDomReadyHeaderItem = OnDomReadyHeaderItem.forScript(scriptTemplate.asString(map));
            scriptTemplate.close();
            response.render(onDomReadyHeaderItem);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : OnDomReadyHeaderItem(org.apache.wicket.markup.head.OnDomReadyHeaderItem) HashMap(java.util.HashMap)

Aggregations

OnDomReadyHeaderItem (org.apache.wicket.markup.head.OnDomReadyHeaderItem)4 HashMap (java.util.HashMap)2 IWrappedHeaderItem (org.apache.wicket.markup.head.IWrappedHeaderItem)1 UrlFragment (org.wicketstuff.urlfragment.UrlFragment)1