public final class FacesViewsUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
WEB_INF_VIEWS |
Modifier and Type | Method and Description |
---|---|
static Application |
getApplication()
Gets the JSF Application instance.
|
static <T> T |
getApplicationAttribute(FacesContext context,
String name) |
static <T> T |
getApplicationAttribute(ServletContext context,
String name) |
static String |
getExtension(String resource)
Gets the extension of a resource if any.
|
static ServletRegistration |
getFacesServletRegistration(ServletContext servletContext)
Gets the ServletRegistration associated with the FacesServlet.
|
static <T> T |
getRequestAttribute(FacesContext context,
String name) |
static boolean |
isDirectory(String resourcePath)
Checks if the given resource path obtained from
ServletContext.getResourcePaths(String) represents a directory. |
static boolean |
isExtensionless(String viewId) |
static Map<String,String> |
scanAndStoreViews(ServletContext context)
Scans for faces-views resources and stores the result at the designated location "org.omnifaces.facesviews"
in the ServletContext.
|
static Map<String,String> |
scanViews(ServletContext servletContext,
Set<String> resourcePaths)
Scans resources (views) recursively starting with the given resource paths and returns a flat map containing all resources
encountered.
|
static void |
scanViews(ServletContext servletContext,
Set<String> resourcePaths,
Map<String,String> collectedViews)
Scans resources (views) recursively starting with the given resource paths, and collects those in a flat map.
|
static void |
scanViews(ServletContext servletContext,
Set<String> resourcePaths,
Map<String,String> collectedViews,
Set<String> collectedExtentions)
Scans resources (views) recursively starting with the given resource paths, and collects those and all unique extensions
encountered in a flat map respectively set.
|
static String |
stripExtension(String resource)
Strips the extension from a resource if any.
|
static String |
stripPrefixPath(String resource)
Strips the special 'faces-views' prefix path from the resource if any.
|
static void |
tryScanAndStoreViews(ServletContext context)
Checks if resources haven't been scanned yet, and if not does scanning and stores the
result at the designated location "org.omnifaces.facesviews" in the ServletContext.
|
public static final String WEB_INF_VIEWS
public static Application getApplication()
public static boolean isDirectory(String resourcePath)
ServletContext.getResourcePaths(String)
represents a directory.resourcePath
- the resource path to checkpublic static String stripPrefixPath(String resource)
resource
- public static String stripExtension(String resource)
resource
- public static String getExtension(String resource)
resource
- public static boolean isExtensionless(String viewId)
public static <T> T getApplicationAttribute(FacesContext context, String name)
public static <T> T getApplicationAttribute(ServletContext context, String name)
public static <T> T getRequestAttribute(FacesContext context, String name)
public static ServletRegistration getFacesServletRegistration(ServletContext servletContext)
servletContext
- the context to get the ServletRegistration from.public static void scanViews(ServletContext servletContext, Set<String> resourcePaths, Map<String,String> collectedViews, Set<String> collectedExtentions)
servletContext
- resourcePaths
- collectedViews
- collectedExtentions
- public static Map<String,String> scanViews(ServletContext servletContext, Set<String> resourcePaths)
servletContext
- resourcePaths
- public static void scanViews(ServletContext servletContext, Set<String> resourcePaths, Map<String,String> collectedViews)
servletContext
- resourcePaths
- collectedViews
- public static void tryScanAndStoreViews(ServletContext context)
context
- public static Map<String,String> scanAndStoreViews(ServletContext context)
context
-