[OmniFaces utilities] The
isDirectory() method checks if the given resource path obtained from ServletContext#getResourcePaths(String) represents a directory.Method:
Usage:
Below you can see a recursive example of using the ResourcePaths#isDirectory():
import
org.omnifaces.util.ResourcePaths;
...
ServletContext
servletContext = (ServletContext) Faces.getExternalContext().getContext();
Set<String>
resourcePaths = servletContext.getResourcePaths("/resources");
scanPaths(servletContext,
resourcePaths);
public void
scanPaths(ServletContext servletContext, Set<String> resourcePaths) {
 resourcePaths.stream().forEach((resourcePath)
-> {
  if (ResourcePaths.isDirectory(resourcePath)) {
      LOG.log(Level.INFO, "Found directory:
{0}", resourcePath);
      scanPaths(servletContext,
servletContext.getResourcePaths(resourcePath));
  } else {
      LOG.log(Level.INFO, "Found file:
{0}", resourcePath);
  }
 });
}
Some
output sample:
Found
directory: /resources/default/
Found
directory: /resources/default/css/
Found file:
/resources/default/css/rafa.css
Found
directory: /resources/default/images/
Found file:
/resources/default/images/rafa.jpg
Found
directory: /resources/default/videos/
Found file:
/resources/default/videos/rafa.avi
...





 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 Ajax
Ajax Beans
Beans Callbacks
Callbacks Components
Components Events
Events Exceptions
Exceptions Faces
Faces Facelets
Facelets JSON
JSON Hacks
Hacks State
State     JNDI
JNDI Platform
Platform Utils
Utils Messages
Messages MapWrapper
MapWrapper Reflection
Reflection Renderers
Renderers ResourcePaths
ResourcePaths XML
XML Servlets
Servlets
 
 <h:inputText/>
<h:inputText/>          ZEEF JSF Beginner's Guide
ZEEF JSF Beginner's Guide       JSF 2 Tutorials at www.mkyong.com
JSF 2 Tutorials at www.mkyong.com      JavaServer Faces (JSF) Tutorial
JavaServer Faces (JSF) Tutorial      

















 
 Postări
Postări
 
 
Niciun comentariu :
Trimiteți un comentariu