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

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

Introduction

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

Prototype

public CharSequence urlFor(IRequestHandler handler) 

Source Link

Document

Returns the rendered URL for the request handler or null if the handler couldn't have been rendered.

Usage

From source file:org.hippoecm.frontend.translation.components.document.DocumentTranslationView.java

License:Apache License

@Override
protected void onRenderProperties(org.json.JSONObject properties) throws JSONException {
    super.onRenderProperties(properties);

    RequestCycle rc = RequestCycle.get();
    properties.put("store", new JSONIdentifier(store.getJsObjectId()));
    properties.put("codecUrl", codecBehavior.getCallbackUrl());
    properties.put("imageService", imageService.getCallbackUrl());

    properties.put("emptyImg", rc.urlFor(new ResourceReferenceRequestHandler(EMPTY_PNG)));
    properties.put("folderImg", rc.urlFor(new ResourceReferenceRequestHandler(FOLDER_PNG)));
    properties.put("documentImg", rc.urlFor(new ResourceReferenceRequestHandler(DOCUMENT_PNG)));
}

From source file:org.hippoecm.frontend.translation.components.folder.FolderTranslationView.java

License:Apache License

@Override
protected void onRenderProperties(JSONObject properties) throws JSONException {
    super.onRenderProperties(properties);

    RequestCycle rc = RequestCycle.get();
    properties.put("root", new JSONIdentifier(root.getJsObjectId()));
    properties.put("loader", new JSONIdentifier(loader.getJsObjectId()));
    properties.put("locator", new JSONIdentifier(locator.getJsObjectId()));
    properties.put("imageService", imageService.getCallbackUrl());
    properties.put("pathRenderer", new JSONIdentifier(pathRenderer.getJsObjectId()));

    JSONObject locales = new JSONObject();
    for (HippoLocale locale : provider.getLocales()) {
        JSONObject jsonLocale = new JSONObject();
        jsonLocale.put("country", locale.getLocale().getCountry());
        locales.put(locale.getName(), jsonLocale);
    }/*from  w  w  w. j  ava 2  s .c om*/
    properties.put("locales", getEscapeModelStrings());

    T9Node folderNode = model.getObject();
    JSONObject folder = new JSONObject();
    folder.put("lang", folderNode.getLang());
    JSONObject siblings = locator.getSiblingsAsJSON(folderNode.getT9id());
    if (siblings.length() > 0) {
        folder.put("siblings", siblings);
    }
    List<T9Node> ancestors = treeModel.getObject().getPath(folderNode.getId());
    JSONArray jsonPath = new JSONArray();
    for (T9Node ancestor : ancestors) {
        JSONObject jsonElement = new JSONObject();
        ExtPropertyConverter.addProperties(ancestor, ancestor.getClass(), jsonElement);
        jsonPath.put(jsonElement);
    }
    folder.put("path", jsonPath);
    properties.put("folder", folder);

    //        properties.put("breakLinkDisabled", rc.urlFor(new PackageResourceReference(getClass(), "broken-link-disabled.png")));
    properties.put("breakLink", rc.urlFor(new ResourceReferenceRequestHandler(
            new PackageResourceReference(getClass(), "unlink-translations-16.png"))));
}

From source file:sf.wicklet.gwt.server.ajax.impl.GwtAjaxWickletTarget.java

License:Apache License

/**
 * @see org.apache.wicket.core.request.handler.IPageRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
 *//*from   w w  w  .j  a va2s.c om*/
@Override
public final void respond(final IRequestCycle requestCycle) {
    final RequestCycle rc = (RequestCycle) requestCycle;
    final WebResponse response = (WebResponse) requestCycle.getResponse();
    if (errorResponse(response)) {
        return;
    }
    if (responseObject.containsPage()) {
        // the page itself has been added to the request target, we simply issue a redirect
        // back to the page
        final IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
        final String url = rc.urlFor(handler).toString();
        response.sendRedirect(url);
        return;
    }
    respondersFrozen = true;
    for (final ITargetRespondListener listener : respondListeners) {
        listener.onTargetRespond(this);
    }
    final Application app = page.getApplication();
    page.send(app, Broadcast.BREADTH, this);
    // Determine encoding
    final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding();
    // Set content type based on markup type for page
    responseObject.setContentType(response, encoding);
    // Make sure it is not cached by a client
    response.disableCaching();
    try {
        final StringResponse bodyResponse = new StringResponse();
        responseObject.writeTo(bodyResponse, encoding);
        final CharSequence filteredResponse = invokeResponseFilters(bodyResponse);
        response.write(filteredResponse);
    } finally {
        // restore the original response
        rc.setResponse(response);
    }
}