Package org.apache.sling.api.request

Examples of org.apache.sling.api.request.RequestDispatcherOptions


        final SlingHttpServletRequest request = TagUtil.getRequest(pageContext);

        // set request dispatcher options according to tag attributes. This
        // depends on the implementation, that using a "null" argument
        // has no effect
        final RequestDispatcherOptions opts = new RequestDispatcherOptions();
        opts.setForceResourceType(resourceType);
        opts.setReplaceSelectors(replaceSelectors);
        opts.setAddSelectors(addSelectors);
        opts.setReplaceSuffix(replaceSuffix);

        // ensure the path (if set) is absolute and normalized
        if (path != null) {
            if (!path.startsWith("/")) {
                path = request.getResource().getPath() + "/" + path;
            }
            path = ResourceUtil.normalize(path);
        }

        // check the resource
        if (resource == null) {
            if (path == null) {
                // neither resource nor path is defined, use current resource
                resource = request.getResource();
            } else {
                // check whether the path (would) resolve, else SyntheticRes.
                Resource tmp = request.getResourceResolver().resolve(path);
                if (tmp == null && resourceType != null) {
                    resource = new DispatcherSyntheticResource(
                        request.getResourceResolver(), path, resourceType);

                    // remove resource type overwrite as synthetic resource
                    // is correctly typed as requested
                    opts.remove(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE);
                }
            }
        }

        try {
View Full Code Here


    /**
     * @see org.apache.sling.api.scripting.SlingScriptHelper#include(java.lang.String, java.lang.String)
     */
    public void include(String path, String options) {
        include(path, new RequestDispatcherOptions(options));
    }
View Full Code Here

    /**
     * @see org.apache.sling.api.scripting.SlingScriptHelper#forward(java.lang.String, java.lang.String)
     */
    public void forward(String path, String options) {
        forward(path, new RequestDispatcherOptions(options));
    }
View Full Code Here

    /**
     * @see org.apache.sling.api.scripting.SlingScriptHelper#forward(org.apache.sling.api.resource.Resource, java.lang.String)
     */
    public void forward(Resource resource, String options) {
        forward(resource, new RequestDispatcherOptions(options));
    }
View Full Code Here

    /**
     * @see org.apache.sling.api.scripting.SlingScriptHelper#include(org.apache.sling.api.resource.Resource, java.lang.String)
     */
    public void include(Resource resource, String options) {
        include(resource, new RequestDispatcherOptions(options));
    }
View Full Code Here

        for (String index : indexFiles) {
            Resource fileRes = resolver.getResource(resource, index);
            if (fileRes != null && !ResourceUtil.isSyntheticResource(fileRes)) {

                // include the index resource with no suffix and selectors !
                RequestDispatcherOptions rdo = new RequestDispatcherOptions();
                rdo.setReplaceSuffix("");
                rdo.setReplaceSelectors("");

                RequestDispatcher dispatcher;
                if (index.indexOf('.') < 0) {
                    String filePath = fileRes.getPath() + ".html";
                    dispatcher = request.getRequestDispatcher(filePath, rdo);
View Full Code Here

                "/some/path", ".s1.s2.ext"));
        assertEquals("s1.s2", p.getSelectorString());
        assertEquals("ext", p.getExtension());

        // test to replace selectors with a new one
        RequestDispatcherOptions o = new RequestDispatcherOptions();
        o.setReplaceSelectors("a");
        RequestPathInfo result = p.merge(o);
        assertEquals("a", result.getSelectorString());
        assertEquals("ext", result.getExtension());

        // test to replace selector with the empty string
        o.setReplaceSelectors("");
        result = p.merge(o);
        assertEquals(null, result.getSelectorString());
        assertEquals("ext", result.getExtension());

        // now add a selector
        o.setAddSelectors("b");
        result = p.merge(o);
        assertEquals("b", result.getSelectorString());
        assertEquals("ext", result.getExtension());

        // replace ext
        o.setReplaceSuffix("html");
        result = p.merge(o);
        assertEquals("b", result.getSelectorString());
        assertEquals("html", result.getSuffix());
    }
View Full Code Here

            String resourcePath = request.getRequestPathInfo().getResourcePath();
            ValidationModel vm = validationService.getValidationModel(resourceType, resourcePath);
            if (vm != null) {
                ValidationResult vr = validationService.validate(requestParameters, vm);
                if (vr.isValid()) {
                    RequestDispatcherOptions options = new RequestDispatcherOptions();
                    options.setReplaceSelectors(" ");
                    request.getRequestDispatcher(request.getResource(), options).forward(request, response);
                } else {
                    response.setContentType("application/json");
                    JSONObject json = new JSONObject();
                    try {
View Full Code Here

    @Override
    public final void forwardAsGet(final Form form, final Page page,
                             final SlingHttpServletRequest request,
                             final SlingHttpServletResponse response) throws ServletException, IOException {

        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        options.setReplaceSelectors("");
        options.setForceResourceType(CQ_PAGE_RESOURCE_TYPE);

        this.forwardAsGet(form, page, request, response, options);
    }
View Full Code Here

    @Override
    public final void forwardAsGet(final Form form, final Resource resource,
                             final SlingHttpServletRequest request,
                             final SlingHttpServletResponse response) throws ServletException, IOException {

        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        this.forwardAsGet(form, resource, request, response, options);
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.api.request.RequestDispatcherOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.