Package org.apache.sling.api.request

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


    @Override
    public final void renderOtherForm(final Form form, final String path, final String formSelector,
                                 final SlingHttpServletRequest request, final SlingHttpServletResponse response)
            throws IOException, ServletException, JSONException {
        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        if (StringUtils.isNotBlank(formSelector)) {
            options.setReplaceSelectors(formSelector);
        }

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


    @Override
    public final void renderOtherForm(final Form form, final Page page, final String formSelector,
                                 final SlingHttpServletRequest request, final SlingHttpServletResponse response)
            throws IOException, ServletException, JSONException {
        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        if (StringUtils.isNotBlank(formSelector)) {
            options.setReplaceSelectors(formSelector);
        }

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

    @Override
    public final void renderOtherForm(final Form form, final Resource resource, final String formSelector,
                                final SlingHttpServletRequest request, final SlingHttpServletResponse response)
            throws IOException, ServletException, JSONException {
        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        if (StringUtils.isNotBlank(formSelector)) {
            options.setReplaceSelectors(formSelector);
        }

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

        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 SyntheticResource(
                        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

        String formSelector = formsRouter.getFormSelector(slingRequest);
        if (formSelector == null) {
            formSelector = FormHelper.DEFAULT_FORM_SELECTOR;
        }

        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        options.setReplaceSelectors(formSelector);
        options.setReplaceSuffix(slingRequest.getRequestPathInfo().getSuffix());

        if (log.isDebugEnabled()) {
            log.debug("Form Filter; Internal forward to path: {} ", formResource);
            log.debug("Form Filter; Internal forward w/ replace selectors: {} ", options.getReplaceSelectors());
            log.debug("Form Filter; Internal forward w/ suffix: {} ", options.getReplaceSuffix());
        }

        slingRequest.getRequestDispatcher(formResource, options).forward(slingRequest, slingResponse);
    }
View Full Code Here

        if (slingRequest.getAttribute(REQUEST_ATTR_PREVIOUSLY_PROCESSED) != null) {
            filterChain.doFilter(servletRequest, servletResponse);
            return;
        }

        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        options.setReplaceSelectors(formSelector);
        options.setReplaceSuffix(slingRequest.getRequestPathInfo().getSuffix());

        if (log.isDebugEnabled()) {
            log.debug("POST-Redirect-GET Form Filter; Internal forward to resource: {} ",
                    slingRequest.getResource());
            log.debug("POST-Redirect-GET Form Filter; Internal forward to path: {} ",
                    slingRequest.getResource().getPath());
            log.debug("POST-Redirect-GET Filter; Internal forward w/ replace selectors: {} ",
                    options.getReplaceSelectors());
            log.debug("POST-Redirect-GET Filter; Internal forward w/ suffix: {} ",
                    options.getReplaceSuffix());
        }

        // Avoid accidental infinite loops with API consumers doing their own Fws and Includes
        slingRequest.setAttribute(REQUEST_ATTR_PREVIOUSLY_PROCESSED, Boolean.TRUE);
        slingRequest.getRequestDispatcher(slingRequest.getResource(), options).forward(slingRequest, slingResponse);
View Full Code Here

     *
     * @param request
     * @param response
     */
    private void delegate(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException {
        final RequestDispatcherOptions options = new RequestDispatcherOptions();

        if(this.isCyclic(request, targetResourceType)) {
            log.error("Delegation Servlet creating a cycle for Target Resource Type: {}", targetResourceType);
            throw new ServletException("Cyclic delegation detected for " + targetResourceType);
        }

        if(StringUtils.isNotBlank(targetResourceType)) {
            log.debug("Delegating Request resource type with: {}", targetResourceType);
            options.setForceResourceType(targetResourceType);
        } else {
            log.warn("Delegating Servlet's \"Target Resource Type\" is blank or null");
        }

        try {
View Full Code Here

        include(path, (RequestDispatcherOptions) null);
    }

    /** Include the output of another request, using specified options */
    public void include(String path, String options) {
        include(path, new RequestDispatcherOptions(options));
    }
View Full Code Here

        include(path, (RequestDispatcherOptions) null);
    }

    /** Include the output of another request, using specified options */
    public void include(String path, String options) {
        include(path, new RequestDispatcherOptions(options));
    }
View Full Code Here

        forward(path, (RequestDispatcherOptions) null);
    }

    /** Forward the request to another resource, using specified options */
    public void forward(String path, String options) {
        forward(path, new RequestDispatcherOptions(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.