Example usage for org.apache.wicket.request.cycle RequestCycle scheduleRequestHandlerAfterCurrent

List of usage examples for org.apache.wicket.request.cycle RequestCycle scheduleRequestHandlerAfterCurrent

Introduction

In this page you can find the example usage for org.apache.wicket.request.cycle RequestCycle scheduleRequestHandlerAfterCurrent.

Prototype

@Override
public void scheduleRequestHandlerAfterCurrent(IRequestHandler handler) 

Source Link

Usage

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

License:Apache License

/**
 * @see org.apache.wicket.behavior.IBehaviorListener#onRequest()
 *//* w  ww  . j a v a2s.com*/
@Override
public final void onRequest() {
    final WebApplication app = (WebApplication) getComponent().getApplication();
    final AjaxRequestTarget target = app.newAjaxRequestTarget(getComponent().getPage());

    final RequestCycle requestCycle = RequestCycle.get();
    requestCycle.scheduleRequestHandlerAfterCurrent(target);

    respond(target);
}

From source file:com.conwax.ajax.SimpleAjaxEventBehavior.java

License:Apache License

public void onRequest() {
    RequestCycle requestCycle = RequestCycle.get();
    SimpleAjaxRequestTarget target = new SimpleAjaxRequestTarget();
    requestCycle.scheduleRequestHandlerAfterCurrent(target);
    onEvent(target);/*from  w ww  .  j  a v a2  s  .  c  o m*/
}

From source file:com.evolveum.midpoint.web.page.admin.resources.PageResourceVisualizationCytoscape.java

License:Apache License

private void initLayout(PrismObject<ResourceType> resourceObject) {
    retrievalBehavior = new AbstractAjaxBehavior() {
        @Override/*w w  w  .  j  a v  a 2 s. co  m*/
        public void onRequest() {
            System.out.println("retrieve CS data: starting");
            RequestCycle requestCycle = getRequestCycle();
            requestCycle.scheduleRequestHandlerAfterCurrent(null);

            MidPointApplication app = (MidPointApplication) MidPointApplication.get();
            TaskManager taskManager = app.getTaskManager();
            Task task = taskManager.createTaskInstance(PageResourceVisualizationCytoscape.class + ".onRequest");

            String jsonData;
            try {
                jsonData = app.getModelDiagnosticService().exportDataModel(resourceObject.asObjectable(),
                        DataModelVisualizer.Target.CYTOSCAPE, task, task.getResult());
                System.out.println("JSON Cytoscape Data:\n" + jsonData);
            } catch (CommonException | RuntimeException e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't visualize resource {}", e,
                        resourceObject);
                jsonData = "{\"nodes\":[], \"edges\":[]}"; // TODO better error handling
            }

            IResource jsonResource = new ByteArrayResource("application/json", jsonData.getBytes());
            IRequestHandler requestHandler = new ResourceRequestHandler(jsonResource, null);
            requestHandler.respond(requestCycle);
            System.out.println("retrieve CS data: response written");
        }
    };
    add(retrievalBehavior);

    deletionBehavior = new AbstractAjaxBehavior() {
        @Override
        public void onRequest() {
            System.out.println("deleteAttribute: starting");
            RequestCycle requestCycle = getRequestCycle();
            requestCycle.scheduleRequestHandlerAfterCurrent(null);

            MidPointApplication app = (MidPointApplication) MidPointApplication.get();
            TaskManager taskManager = app.getTaskManager();
            Task task = taskManager.createTaskInstance(PageResourceVisualizationCytoscape.class + ".onRequest");

            try {
                IRequestParameters parameters = requestCycle.getRequest().getQueryParameters();
                String resourceOid = parameters.getParameterValue("resourceOid").toString();
                String kind = parameters.getParameterValue("kind").toString();
                String intent = parameters.getParameterValue("intent").toString();
                String objectClass = parameters.getParameterValue("objectClass").toString();
                String attributeName = parameters.getParameterValue("attributeName").toString();
                System.out.println("ResourceOid: " + resourceOid + ", kind: " + kind + ", intent: " + intent
                        + ", objectClass: " + objectClass + ", attributeName: " + attributeName);
            } catch (RuntimeException e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete attribute", e);
            }

            IResource resource = new ByteArrayResource("text/plain", "OK".getBytes());
            IRequestHandler requestHandler = new ResourceRequestHandler(resource, null);
            requestHandler.respond(requestCycle);
            System.out.println("deleteAttribute: finished");
        }
    };
    add(deletionBehavior);
}

From source file:com.gitblit.wicket.GitblitRedirectException.java

License:Apache License

public <C extends Page> GitblitRedirectException(Class<C> pageClass, PageParameters params) {
    super(pageClass, params);
    RequestCycle cycle = RequestCycle.get();
    String absoluteUrl = GitBlitRequestUtils.toAbsoluteUrl(pageClass, params);
    cycle.scheduleRequestHandlerAfterCurrent(new RedirectRequestHandler(absoluteUrl));
}

From source file:com.googlecode.wicket.jquery.core.behavior.AjaxCallbackBehavior.java

License:Apache License

/**
 * {@inheritDoc}<br>//from   w w w .j av  a 2s.  co  m
 * <br>
 * <b>Warning:</b> Overridden methods should call {@code super.onRequest()}
 */
@Override
public void onRequest() {
    RequestCycle requestCycle = RequestCycle.get();
    requestCycle.scheduleRequestHandlerAfterCurrent(new TextRequestHandler(this.mimetype, this.encoding,
            this.getResponse(requestCycle.getRequest().getQueryParameters())));
}

From source file:com.googlecode.wicket.jquery.ui.calendar.CalendarModelBehavior.java

License:Apache License

@Override
public void onRequest() {
    final RequestCycle requestCycle = RequestCycle.get();
    IRequestParameters parameters = requestCycle.getRequest().getQueryParameters();

    final long start = parameters.getParameterValue("start").toLong(0);
    final long end = parameters.getParameterValue("end").toLong(0);

    if (this.model != null) {
        this.model.setStart(new Date(start * 1000));
        this.model.setEnd(new Date(end * 1000));
    }/*from  ww  w.ja  va2  s.c o  m*/

    final IRequestHandler handler = this.newRequestHandler();
    requestCycle.scheduleRequestHandlerAfterCurrent(handler);
}

From source file:com.googlecode.wicket.jquery.ui.form.autocomplete.AutoCompleteSourceBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    final RequestCycle requestCycle = RequestCycle.get();
    final String value = requestCycle.getRequest().getQueryParameters().getParameterValue(QUERY).toString();

    final IRequestHandler handler = this.newRequestHandler(value);
    requestCycle.scheduleRequestHandlerAfterCurrent(handler);
}

From source file:com.googlecode.wicket.jquery.ui.kendo.datatable.DataSourceBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    final RequestCycle requestCycle = RequestCycle.get();
    final int first = requestCycle.getRequest().getQueryParameters().getParameterValue("skip").toInt(0);
    final int count = requestCycle.getRequest().getQueryParameters().getParameterValue("take").toInt(0);

    final IRequestHandler handler = this.newRequestHandler(first, count);
    requestCycle.scheduleRequestHandlerAfterCurrent(handler);
}

From source file:com.googlecode.wicket.kendo.ui.datatable.DataProviderBehavior.java

License:Apache License

@Override
public void onRequest() {
    final RequestCycle requestCycle = RequestCycle.get();
    final IRequestParameters parameters = requestCycle.getRequest().getQueryParameters();

    final int first = parameters.getParameterValue("skip").toInt(0);
    final int count = parameters.getParameterValue("take").toInt(0);

    // ISortStateLocator //
    if (this.provider instanceof ISortStateLocator<?>) {
        String property = parameters.getParameterValue("sort[0][field]").toOptionalString();
        String direction = parameters.getParameterValue("sort[0][dir]").toOptionalString();

        if (property != null) {
            this.setSort(PropertyUtils.unescape(property), direction == null ? SortOrder.NONE
                    : direction.equals(ASC) ? SortOrder.ASCENDING : SortOrder.DESCENDING);
        }/* w  w w .  ja  v  a2 s.  com*/
    }

    // IFilterStateLocator //
    if (this.provider instanceof IFilterStateLocator<?>) {
        @SuppressWarnings("unused")
        String logicPattern = "filter[logic]";
        String fieldPattern = "filter[filters][%d][field]";
        String valuePattern = "filter[filters][%d][value]";

        @SuppressWarnings("unused")
        String operatorPattern = "filter[filters][%d][operator]";
        // TODO: implement logic & operator (new IFilterStateLocator interface?)

        @SuppressWarnings("unchecked")
        T object = ((IFilterStateLocator<T>) this.provider).getFilterState();
        PropertyResolverConverter converter = this.newPropertyResolverConverter();

        for (int i = 0; i < COLS; i++) {
            String field = parameters.getParameterValue(String.format(fieldPattern, i)).toOptionalString();
            String value = parameters.getParameterValue(String.format(valuePattern, i)).toOptionalString();

            if (field != null) {
                PropertyResolver.setValue(PropertyUtils.unescape(field), object, value, converter);
            } else {
                break;
            }
        }
    }

    requestCycle.scheduleRequestHandlerAfterCurrent(this.newRequestHandler(first, count));
}

From source file:com.googlecode.wicket.kendo.ui.datatable.DataSourceBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    final RequestCycle requestCycle = RequestCycle.get();
    final IRequestParameters parameters = requestCycle.getRequest().getQueryParameters();

    final int first = parameters.getParameterValue("skip").toInt(0);
    final int count = parameters.getParameterValue("take").toInt(0);

    // ISortStateLocator //
    if (this.provider instanceof ISortStateLocator<?>) {
        String property = parameters.getParameterValue("sort[0][field]").toOptionalString();
        String direction = parameters.getParameterValue("sort[0][dir]").toOptionalString();

        if (property != null) {
            this.setSort(PropertyUtils.unescape(property), direction == null ? SortOrder.NONE
                    : direction.equals(ASC) ? SortOrder.ASCENDING : SortOrder.DESCENDING);
        }//from  w w w  . j av  a  2 s.  c o  m
    }

    // IFilterStateLocator //
    if (this.provider instanceof IFilterStateLocator<?>) {
        String fieldPattern = "filter[filters][%d][field]";
        String valuePattern = "filter[filters][%d][value]";

        @SuppressWarnings("unused")
        String logicPattern = "filter[logic]";
        @SuppressWarnings("unused")
        String operatorPattern = "filter[filters][%d][operator]";
        // TODO: implement logic & operator (new IFilterStateLocator interface?)

        @SuppressWarnings("unchecked")
        T object = ((IFilterStateLocator<T>) this.provider).getFilterState();
        PropertyResolverConverter converter = this.newPropertyResolverConverter();

        for (int i = 0; i < COLS; i++) {
            String field = parameters.getParameterValue(String.format(fieldPattern, i)).toOptionalString();
            String value = parameters.getParameterValue(String.format(valuePattern, i)).toOptionalString();

            if (field != null) {
                PropertyResolver.setValue(PropertyUtils.unescape(field), object, value, converter);
            } else {
                break;
            }
        }
    }

    final IRequestHandler handler = this.newRequestHandler(first, count);
    requestCycle.scheduleRequestHandlerAfterCurrent(handler);
}