-
Available since OmniFaces 1.2
This configuration interface parses the /WEB-INF/web.xml
and all /META-INF/web-fragment
files found in the classpath and offers methods to obtain information from them which is not available by the standard Servlet API.
Usage
Some examples:
// Get the <welcome-file-list> (which are essentially path-relative filenames which needs to be served when a folder is requested).
List<String> welcomeFiles = WebXml.instance().getWelcomeFiles();
// Get a mapping of all error page locations by exception type (a key of null represents the default error page location, if any).
Map<Class<Throwable>, String> errorPageLocations = WebXml.instance().getErrorPageLocations();
// Get the <form-login-page> (which is a context-relative URL to the login page of FORM based authentication).
String formLoginPage = WebXml.instance().getFormLoginPage();
// Get a mapping of all <security-constraint> URL patterns and associated roles.
Map<String, Set<String>> securityConstraints = WebXml.instance().getSecurityConstraints();
// Check if access to certain (context-relative) URL is allowed for the given role based on <security-constraint>.
boolean accessAllowed = WebXml.instance().isAccessAllowed("/admin.xhtml", "admin");
// Get web.xml configured session timeout (in minutes).
int sessionTimeout = WebXml.instance().getSessionTimeout();
Since OmniFaces 3.1, you can if necessary even inject it.
@Inject
private WebXml webXml;
Feature request
If you know more useful methods/functions which you think should be added to this OmniFaces utility class so that everyone can benefit from a "standard" Faces utility library, feel free to post a feature request.
Documentation & Sources