Package org.apache.myfaces.shared_impl.webapp.webxml

Examples of org.apache.myfaces.shared_impl.webapp.webxml.ServletMapping


            } catch (ClassNotFoundException e) {
                throw new IllegalArgumentException("Could not load the servlet class " + servletInfo.servletClass, e);
            }
            if (isFacesServlet(servletClass)) {
                for (String urlPattern : servletInfo.servletMappings)
                    facesServletMappings.add(new ServletMapping(servletInfo.servletName, servletClass, urlPattern));
            }
        }
        facesExtensionsFilterMapppings = new ArrayList<FilterMapping>();
        for (FilterInfo filterInfo : webAppInfo.filters) {
            Class<?> filterClass;
View Full Code Here


        if (PortletUtil.isPortletRequest(facesContext)) {
            externalContext.dispatch(viewId);
            return;
        }

        ServletMapping servletMapping = getServletMapping(externalContext);

        if (servletMapping != null && servletMapping.isExtensionMapping()) {
            String defaultSuffix = externalContext.getInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME);
            String suffix = defaultSuffix != null ? defaultSuffix : ViewHandler.DEFAULT_SUFFIX;
            DebugUtils.assertError(suffix.charAt(0) == '.',
                                   log, "Default suffix must start with a dot!");
            if (!viewId.endsWith(suffix)) {
View Full Code Here

        if (PortletUtil.isPortletRequest(facescontext)) {
            return viewId;
        }

        ServletMapping servletMapping = getServletMapping(facescontext.getExternalContext());

        if (servletMapping != null) {
            if (servletMapping.isExtensionMapping()) {
                // extension mapping
                String urlpattern = servletMapping.getUrlPattern();
                if (urlpattern.startsWith("*")) {
                    urlpattern = urlpattern.substring(1, urlpattern.length());
                }
                if (viewId.endsWith(urlpattern)) {
                    return viewId;
                }
                else {
                    int idx = viewId.lastIndexOf(".");
                    if (idx >= 0) {
                        return viewId.substring(0, idx) + urlpattern;
                    }
                    else {
                        return viewId + urlpattern;
                    }

                }
            }
            else {
                // prefix mapping
                String urlpattern = servletMapping.getUrlPattern();
                if (urlpattern.endsWith("/*")) {
                    urlpattern = urlpattern.substring(0, urlpattern.length() - 2);
                }
                return urlpattern + viewId;
            }
View Full Code Here


        if (requestPathInfo == null) {
            // might be extension mapping
            for (int i = 0, size = mappings.size(); i < size; i++) {
                ServletMapping servletMapping = (ServletMapping) mappings.get(i);
                String urlpattern = servletMapping.getUrlPattern();
                String extension = urlpattern.substring(1, urlpattern.length());
                if (servletPath.endsWith(extension)) {
                    return servletMapping;
                }
                else if (servletPath.equals(urlpattern)) {
                    // path mapping with no pathInfo for the current request
                    return servletMapping;
                }
            }
        }
        else {
            // path mapping
            for (int i = 0, size = mappings.size(); i < size; i++) {

                ServletMapping servletMapping = (ServletMapping) mappings.get(i);
                String urlpattern = servletMapping.getUrlPattern();
                urlpattern = urlpattern.substring(0, urlpattern.length() - 2);
                // servletPath starts with "/" except in the case where the
                // request is matched with the "/*" pattern, in which case
                // it is the empty string (see Servlet Sepc 2.3 SRV4.4)
                if (servletPath.equals(urlpattern)) {
View Full Code Here

    private static final Log log = LogFactory.getLog(DefaultViewHandlerSupport.class);

    public String calculateViewId(FacesContext context, String viewId)
    {
        ServletMapping mapping = calculateServletMapping(context);
        if (mapping == null || mapping.isExtensionMapping())
        {
            viewId = applyDefaultSuffix(context, viewId);
        }
        else if (mapping != null && viewId != null && mapping.getUrlPattern().startsWith(viewId))
        {
            throw new InvalidViewIdException(viewId);
        }
        return viewId;
    }
View Full Code Here

    public String calculateActionURL(FacesContext context, String viewId)
    {
        if (viewId == null || !viewId.startsWith("/"))
            throw new IllegalArgumentException("ViewId must start with a '/': " + viewId);

        ServletMapping mapping = calculateServletMapping(context);
        ExternalContext externalContext = context.getExternalContext();
        String contextPath = externalContext.getRequestContextPath();
        StringBuilder builder = new StringBuilder(contextPath);
        if (mapping != null)
        {
            if (mapping.isExtensionMapping())
            {
                String contextSuffix = getContextSuffix(context);
                if (viewId.endsWith(contextSuffix))
                {
                    builder.append(viewId.substring(0, viewId.indexOf(contextSuffix)));
                    builder.append(mapping.getExtension());
                }
                else
                {
                    builder.append(viewId);
                }
            }
            else
            {
                builder.append(mapping.getPrefix());
                builder.append(viewId);
            }
        }
        else
        {
View Full Code Here

    protected ServletMapping calculateServletMapping(FacesContext context)
    {
        ExternalContext externalContext = context.getExternalContext();
        Map<String, Object> requestMap = externalContext.getRequestMap();
        ServletMapping mapping = null;
        if (requestMap.containsKey(externalContext))
        {
            mapping = (ServletMapping) requestMap.get(SERVLET_MAPPING);
        }
        else
        {
            String servletPath = externalContext.getRequestServletPath();
            String requestPathInfo = externalContext.getRequestPathInfo();

            WebXml webxml = WebXml.getWebXml(externalContext);
            List mappings = webxml.getFacesServletMappings();

            if (requestPathInfo == null)
            {
                // might be extension mapping
                for (int i = 0, size = mappings.size(); i < size && mapping == null; i++)
                {
                    ServletMapping servletMapping = (ServletMapping) mappings.get(i);
                    String urlpattern = servletMapping.getUrlPattern();
                    String extension = urlpattern.substring(1, urlpattern.length());
                    if (servletPath.endsWith(extension))
                    {
                        mapping = servletMapping;
                    }
                    else if (servletPath.equals(urlpattern))
                    {
                        // path mapping with no pathInfo for the current request
                        mapping = servletMapping;
                    }
                }
            }
            else
            {
                // path mapping
                for (int i = 0, size = mappings.size(); i < size && mapping == null; i++)
                {

                    ServletMapping servletMapping = (ServletMapping) mappings.get(i);
                    String urlpattern = servletMapping.getUrlPattern();
                    urlpattern = urlpattern.substring(0, urlpattern.length() - 2);
                    // servletPath starts with "/" except in the case where the
                    // request is matched with the "/*" pattern, in which case
                    // it is the empty string (see Servlet Sepc 2.3 SRV4.4)
                    if (servletPath.equals(urlpattern))
View Full Code Here

        if (PortletUtil.isPortletRequest(facesContext)) {
            externalContext.dispatch(viewId);
            return;
        }

        ServletMapping servletMapping = getServletMapping(externalContext);

        if (servletMapping != null && servletMapping.isExtensionMapping()) {
            String defaultSuffix = externalContext.getInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME);
            String suffix = defaultSuffix != null ? defaultSuffix : ViewHandler.DEFAULT_SUFFIX;
            DebugUtils.assertError(suffix.charAt(0) == '.',
                                   log, "Default suffix must start with a dot!");
            if (!viewId.endsWith(suffix)) {
View Full Code Here

        if (PortletUtil.isPortletRequest(facescontext)) {
            return viewId;
        }

        ServletMapping servletMapping = getServletMapping(facescontext.getExternalContext());

        if (servletMapping != null) {
            if (servletMapping.isExtensionMapping()) {
                // extension mapping
                String urlpattern = servletMapping.getUrlPattern();
                if (urlpattern.startsWith("*")) {
                    urlpattern = urlpattern.substring(1, urlpattern.length());
                }
                if (viewId.endsWith(urlpattern)) {
                    return viewId;
                }
                else {
                    int slashPos = viewId.lastIndexOf('/');
                    int extensionPos = viewId.lastIndexOf('.');
                   
                    if (extensionPos == -1 || extensionPos <= slashPos) {
                        return viewId + urlpattern;
                    }
                    else {
                        return viewId.substring(0, extensionPos) + urlpattern;
                    }

                }
            }
            else {
                // prefix mapping
                String urlpattern = servletMapping.getUrlPattern();
                if (urlpattern.endsWith("/*")) {
                    urlpattern = urlpattern.substring(0, urlpattern.length() - 2);
                }
                return urlpattern + viewId;
            }
View Full Code Here


        if (requestPathInfo == null) {
            // might be extension mapping
            for (int i = 0, size = mappings.size(); i < size; i++) {
                ServletMapping servletMapping = (ServletMapping) mappings.get(i);
                String urlpattern = servletMapping.getUrlPattern();
                String extension = urlpattern.substring(1, urlpattern.length());
                if (servletPath.endsWith(extension)) {
                    return servletMapping;
                }
                else if (servletPath.equals(urlpattern)) {
                    // path mapping with no pathInfo for the current request
                    return servletMapping;
                }
            }
        }
        else {
            // path mapping
            for (int i = 0, size = mappings.size(); i < size; i++) {

                ServletMapping servletMapping = (ServletMapping) mappings.get(i);
                String urlpattern = servletMapping.getUrlPattern();
                urlpattern = urlpattern.substring(0, urlpattern.length() - 2);
                // servletPath starts with "/" except in the case where the
                // request is matched with the "/*" pattern, in which case
                // it is the empty string (see Servlet Sepc 2.3 SRV4.4)
                if (servletPath.equals(urlpattern)) {
View Full Code Here

TOP

Related Classes of org.apache.myfaces.shared_impl.webapp.webxml.ServletMapping

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.