Example usage for org.apache.wicket.ajax.attributes ThrottlingSettings getId

List of usage examples for org.apache.wicket.ajax.attributes ThrottlingSettings getId

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.attributes ThrottlingSettings getId.

Prototype

public String getId() 

Source Link

Document

This id is used by the client-side throttling code to keep track of the various event throttles.

Usage

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.AbstractMultiAjaxBehavior.java

License:Apache License

/**
 * /*from  w w w  . ja va 2 s. c  o m*/
 * @param component
 * @param attributes
 * @return the attributes as string in JSON format
 */
protected final CharSequence renderAjaxAttributes(final Component component,
        final AjaxRequestAttributes attributes) {
    final JSONObject attributesJson = new JSONObject();

    try {
        attributesJson.put("u", getCallbackUrl());

        appendIfNotEmpty(attributesJson, "f", attributes.getFormId());
        appendBooleanIf(attributesJson, "mp", attributes.isMultipart(), true);
        appendIfNotEmpty(attributesJson, "sc", attributes.getSubmittingComponentName());
        appendIfNotEmpty(attributesJson, "i", findIndicatorId());
        appendListenerAtts(attributesJson, attributes.getAjaxCallListeners());
        appendDynamicExtraParameters(attributes.getDynamicExtraParameters(), attributesJson);
        appendBooleanIf(attributesJson, "async", attributes.isAsynchronous(), false);
        appendBooleanIf(attributesJson, "ad", attributes.isAllowDefault(), true);
        appendBooleanIf(attributesJson, "wr", attributes.isWicketAjaxResponse(), false);

        appendSpecial(attributesJson, attributes);

        final ThrottlingSettings throttlingSettings = attributes.getThrottlingSettings();
        if (throttlingSettings != null) {
            final JSONObject throttlingSettingsJson = new JSONObject();
            throttlingSettingsJson.put("id", throttlingSettings.getId());
            throttlingSettingsJson.put("d", throttlingSettings.getDelay().getMilliseconds());
            appendBooleanIf(throttlingSettingsJson, "p", throttlingSettings.getPostponeTimerOnUpdate(), true);
            attributesJson.put("tr", throttlingSettingsJson);
        }

        postprocessConfiguration(attributesJson, component);
    } catch (JSONException e) {
        throw new WicketRuntimeException(e);
    }

    return attributesJson.toString();
}