All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.omnifaces.facesviews.FacesViewsResolver Maven / Gradle / Ivy

There is a newer version: 4.4.1
Show newest version
/*
 * Copyright 2012 OmniFaces.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package org.omnifaces.facesviews;

import static org.omnifaces.facesviews.FacesViews.getMappedPath;
import static org.omnifaces.facesviews.FacesViews.scanAndStoreViews;
import static org.omnifaces.util.Faces.getServletContext;
import static org.omnifaces.util.Faces.isDevelopment;

import java.net.URL;

import javax.faces.view.facelets.ResourceResolver;

/**
 * Facelets resource resolver that resolves mapped resources (views) to the folders from which
 * those views were scanned (like the the special auto-scanned faces-views folder).
 * 

* For a guide on FacesViews, please see the package summary. * * @author Arjan Tijms * */ public class FacesViewsResolver extends ResourceResolver { private final ResourceResolver resourceResolver; public FacesViewsResolver(ResourceResolver resourceResolver) { this.resourceResolver = resourceResolver; } @Override public URL resolveUrl(String path) { URL resource = resourceResolver.resolveUrl(getMappedPath(path)); if (resource == null && isDevelopment()) { // If "resource" is null it means it wasn't found. Check if the resource was dynamically added by // scanning the faces-views location(s) again. scanAndStoreViews(getServletContext()); resource = resourceResolver.resolveUrl(getMappedPath(path)); } return resource; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy