{"payload":{"allShortcutsEnabled":false,"fileTree":{"src/main/java/org/omnifaces/util":{"items":[{"name":"cache","path":"src/main/java/org/omnifaces/util/cache","contentType":"directory"},{"name":"copier","path":"src/main/java/org/omnifaces/util/copier","contentType":"directory"},{"name":"selectitems","path":"src/main/java/org/omnifaces/util/selectitems","contentType":"directory"},{"name":"Ajax.java","path":"src/main/java/org/omnifaces/util/Ajax.java","contentType":"file"},{"name":"Beans.java","path":"src/main/java/org/omnifaces/util/Beans.java","contentType":"file"},{"name":"BeansLocal.java","path":"src/main/java/org/omnifaces/util/BeansLocal.java","contentType":"file"},{"name":"Callback.java","path":"src/main/java/org/omnifaces/util/Callback.java","contentType":"file"},{"name":"Components.java","path":"src/main/java/org/omnifaces/util/Components.java","contentType":"file"},{"name":"Events.java","path":"src/main/java/org/omnifaces/util/Events.java","contentType":"file"},{"name":"Exceptions.java","path":"src/main/java/org/omnifaces/util/Exceptions.java","contentType":"file"},{"name":"Facelets.java","path":"src/main/java/org/omnifaces/util/Facelets.java","contentType":"file"},{"name":"Faces.java","path":"src/main/java/org/omnifaces/util/Faces.java","contentType":"file"},{"name":"FacesLocal.java","path":"src/main/java/org/omnifaces/util/FacesLocal.java","contentType":"file"},{"name":"Hacks.java","path":"src/main/java/org/omnifaces/util/Hacks.java","contentType":"file"},{"name":"JNDI.java","path":"src/main/java/org/omnifaces/util/JNDI.java","contentType":"file"},{"name":"JNDIObjectLocator.java","path":"src/main/java/org/omnifaces/util/JNDIObjectLocator.java","contentType":"file"},{"name":"Json.java","path":"src/main/java/org/omnifaces/util/Json.java","contentType":"file"},{"name":"Lazy.java","path":"src/main/java/org/omnifaces/util/Lazy.java","contentType":"file"},{"name":"MapWrapper.java","path":"src/main/java/org/omnifaces/util/MapWrapper.java","contentType":"file"},{"name":"Messages.java","path":"src/main/java/org/omnifaces/util/Messages.java","contentType":"file"},{"name":"MessagesLocal.java","path":"src/main/java/org/omnifaces/util/MessagesLocal.java","contentType":"file"},{"name":"Platform.java","path":"src/main/java/org/omnifaces/util/Platform.java","contentType":"file"},{"name":"Reflection.java","path":"src/main/java/org/omnifaces/util/Reflection.java","contentType":"file"},{"name":"Renderers.java","path":"src/main/java/org/omnifaces/util/Renderers.java","contentType":"file"},{"name":"ResourcePaths.java","path":"src/main/java/org/omnifaces/util/ResourcePaths.java","contentType":"file"},{"name":"Servlets.java","path":"src/main/java/org/omnifaces/util/Servlets.java","contentType":"file"},{"name":"State.java","path":"src/main/java/org/omnifaces/util/State.java","contentType":"file"},{"name":"Utils.java","path":"src/main/java/org/omnifaces/util/Utils.java","contentType":"file"},{"name":"Validators.java","path":"src/main/java/org/omnifaces/util/Validators.java","contentType":"file"},{"name":"Xml.java","path":"src/main/java/org/omnifaces/util/Xml.java","contentType":"file"}],"totalCount":30},"src/main/java/org/omnifaces":{"items":[{"name":"application","path":"src/main/java/org/omnifaces/application","contentType":"directory"},{"name":"cdi","path":"src/main/java/org/omnifaces/cdi","contentType":"directory"},{"name":"component","path":"src/main/java/org/omnifaces/component","contentType":"directory"},{"name":"config","path":"src/main/java/org/omnifaces/config","contentType":"directory"},{"name":"context","path":"src/main/java/org/omnifaces/context","contentType":"directory"},{"name":"converter","path":"src/main/java/org/omnifaces/converter","contentType":"directory"},{"name":"el","path":"src/main/java/org/omnifaces/el","contentType":"directory"},{"name":"event","path":"src/main/java/org/omnifaces/event","contentType":"directory"},{"name":"eventlistener","path":"src/main/java/org/omnifaces/eventlistener","contentType":"directory"},{"name":"exceptionhandler","path":"src/main/java/org/omnifaces/exceptionhandler","contentType":"directory"},{"name":"facesviews","path":"src/main/java/org/omnifaces/facesviews","contentType":"directory"},{"name":"filter","path":"src/main/java/org/omnifaces/filter","contentType":"directory"},{"name":"io","path":"src/main/java/org/omnifaces/io","contentType":"directory"},{"name":"model","path":"src/main/java/org/omnifaces/model","contentType":"directory"},{"name":"renderer","path":"src/main/java/org/omnifaces/renderer","contentType":"directory"},{"name":"resourcehandler","path":"src/main/java/org/omnifaces/resourcehandler","contentType":"directory"},{"name":"servlet","path":"src/main/java/org/omnifaces/servlet","contentType":"directory"},{"name":"taghandler","path":"src/main/java/org/omnifaces/taghandler","contentType":"directory"},{"name":"util","path":"src/main/java/org/omnifaces/util","contentType":"directory"},{"name":"validator","path":"src/main/java/org/omnifaces/validator","contentType":"directory"},{"name":"viewhandler","path":"src/main/java/org/omnifaces/viewhandler","contentType":"directory"},{"name":"ApplicationInitializer.java","path":"src/main/java/org/omnifaces/ApplicationInitializer.java","contentType":"file"},{"name":"ApplicationListener.java","path":"src/main/java/org/omnifaces/ApplicationListener.java","contentType":"file"},{"name":"ApplicationProcessor.java","path":"src/main/java/org/omnifaces/ApplicationProcessor.java","contentType":"file"}],"totalCount":24},"src/main/java/org":{"items":[{"name":"omnifaces","path":"src/main/java/org/omnifaces","contentType":"directory"}],"totalCount":1},"src/main/java":{"items":[{"name":"org","path":"src/main/java/org","contentType":"directory"}],"totalCount":1},"src/main":{"items":[{"name":"java","path":"src/main/java","contentType":"directory"},{"name":"resources","path":"src/main/resources","contentType":"directory"}],"totalCount":2},"src":{"items":[{"name":"main","path":"src/main","contentType":"directory"},{"name":"test","path":"src/test","contentType":"directory"}],"totalCount":2},"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"contributors.txt","path":"contributors.txt","contentType":"file"},{"name":"license.txt","path":"license.txt","contentType":"file"},{"name":"package-lock.json","path":"package-lock.json","contentType":"file"},{"name":"package.json","path":"package.json","contentType":"file"},{"name":"pom.xml","path":"pom.xml","contentType":"file"},{"name":"tsconfig.json","path":"tsconfig.json","contentType":"file"}],"totalCount":10}},"fileTreeProcessingTime":30.762546,"foldersToFetch":[],"repo":{"id":18062770,"defaultBranch":"4.x","name":"omnifaces","ownerLogin":"omnifaces","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2014-03-24T13:05:53.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/7047175?v=4","public":true,"private":false,"isOrgOwned":true},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"4.x","listCacheKey":"v0:1710012196.0","canEdit":false,"refType":"branch","currentOid":"df583bf37871ab165a832bff71c5dc2113b1cce4"},"path":"src/main/java/org/omnifaces/util/Faces.java","currentUser":null,"blob":{"rawLines":["/*"," * Copyright 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"," *"," * https://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.util;","","import static jakarta.faces.FactoryFinder.APPLICATION_FACTORY;","","import java.io.File;","import java.io.FileInputStream;","import java.io.IOException;","import java.io.InputStream;","import java.io.UncheckedIOException;","import java.net.MalformedURLException;","import java.net.URL;","import java.nio.file.Path;","import java.util.Collection;","import java.util.List;","import java.util.Locale;","import java.util.Map;","import java.util.MissingResourceException;","import java.util.ResourceBundle;","import java.util.Set;","import java.util.function.Function;","import java.util.function.Supplier;","","import jakarta.el.ELContext;","import jakarta.el.ELResolver;","import jakarta.el.ExpressionFactory;","import jakarta.el.ValueExpression;","import jakarta.faces.FacesException;","import jakarta.faces.FactoryFinder;","import jakarta.faces.application.Application;","import jakarta.faces.application.ApplicationFactory;","import jakarta.faces.application.NavigationHandler;","import jakarta.faces.application.ProjectStage;","import jakarta.faces.application.Resource;","import jakarta.faces.application.ResourceHandler;","import jakarta.faces.application.ViewHandler;","import jakarta.faces.component.UIViewParameter;","import jakarta.faces.component.UIViewRoot;","import jakarta.faces.context.ExternalContext;","import jakarta.faces.context.FacesContext;","import jakarta.faces.context.FacesContextWrapper;","import jakarta.faces.context.Flash;","import jakarta.faces.context.PartialViewContext;","import jakarta.faces.convert.Converter;","import jakarta.faces.convert.ConverterException;","import jakarta.faces.convert.FacesConverter;","import jakarta.faces.event.PhaseId;","import jakarta.faces.lifecycle.Lifecycle;","import jakarta.faces.lifecycle.LifecycleFactory;","import jakarta.faces.render.RenderKit;","import jakarta.faces.validator.FacesValidator;","import jakarta.faces.validator.Validator;","import jakarta.faces.view.ViewDeclarationLanguage;","import jakarta.faces.view.ViewMetadata;","import jakarta.faces.view.facelets.FaceletContext;","import jakarta.servlet.ServletContext;","import jakarta.servlet.ServletException;","import jakarta.servlet.http.HttpServletRequest;","import jakarta.servlet.http.HttpServletResponse;","import jakarta.servlet.http.HttpSession;","import jakarta.servlet.http.Part;","","import org.omnifaces.component.ParamHolder;","import org.omnifaces.component.input.HashParam;","import org.omnifaces.component.input.ScriptParam;","import org.omnifaces.config.FacesConfigXml;","import org.omnifaces.el.FacesELResolver;","import org.omnifaces.facesviews.FacesViews;","import org.omnifaces.filter.MutableRequestFilter;","import org.omnifaces.filter.MutableRequestFilter.MutableRequest;","import org.omnifaces.resourcehandler.ResourceIdentifier;","","/**"," *
"," * Collection of utility methods for the Faces API that are mainly shortcuts for obtaining stuff from the thread local"," * {@link FacesContext}. In effects, it 'flattens' the hierarchy of nested objects. Do note that using the hierarchy is"," * actually a better software design practice, but can lead to verbose code."," *
"," * Next to those oneliner delegate calls, there are also some helpful methods which eliminates multiline boilerplate"," * code, such as {@link #getLocale()} which returns sane fallback values, a more convenient"," * {@link #redirect(String, Object...)} which automatically prepends the context path when the path does not start with"," * /
and offers support for URL encoding of request parameters supplied by varargs argument, and several"," * useful {@link #sendFile(File, boolean)} methods which allows you to provide a {@link File}, byte[]
or"," * {@link InputStream} as a download to the client."," *"," *
"," * Here are some examples:"," *
"," * // Get a session attribute (no explicit cast necessary!)."," * User user = Faces.getSessionAttribute(\"user\");"," *"," *
"," * // Evaluate EL programmatically (no explicit cast necessary!)."," * Item item = Faces.evaluateExpressionGet(\"#{item}\");"," *"," *
"," * // Get a cookie value."," * String cookieValue = Faces.getRequestCookie(\"cookieName\");"," *"," *
"," * // Get all supported locales with default locale as first item."," * List<Locale> supportedLocales = Faces.getSupportedLocales();"," *"," *
"," * // Check in e.g. preRenderView if session has been timed out."," * if (Faces.hasSessionTimedOut()) {"," * Messages.addGlobalWarn(\"Oops, you have been logged out because your session was been timed out!\");"," * }"," *"," *
"," * // Get value of <f:metadata><f:attribute name=\"foo\"> of different view without building it."," * String foo = Faces.getMetadataAttribute(\"/other.xhtml\", \"foo\");"," *"," *
"," * // Send a redirect with parameters UTF-8 encoded in query string."," * Faces.redirect(\"product.xhtml?id=%d&name=%s\", product.getId(), product.getName());"," *"," *
"," * // Invalidate the session and send a redirect."," * public void logout() {"," * Faces.invalidateSession();"," * Faces.redirect(\"login.xhtml\"); // Can by the way also be done by return \"login?faces-redirect=true\" if in action method."," * }"," *"," *
"," * // Provide a file as attachment."," * public void download() {"," * Faces.sendFile(new File(\"/path/to/file.ext\"), true);"," * }"," *"," *
"," * // Provide a file as attachment via output stream callback."," * public void download() {"," * Faces.sendFile(\"file.txt\", true, output -> {"," * try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8))) {"," * writer.println(\"Hello world\");"," * }"," * });"," * }"," *"," *
"," * For a full list, check the method summary."," *"," *
"," * Note that there's normally a minor overhead in obtaining the thread local {@link FacesContext}. In case client code"," * needs to call methods in this class multiple times it's expected that performance will be slightly better if instead"," * the {@link FacesContext} is obtained once and the required methods are called on that, although the difference is"," * practically negligible when used in modern server hardware."," *
"," * In such case, consider using {@link FacesLocal} instead. The difference with {@link Faces} is that no one method of"," * {@link FacesLocal} obtains the {@link FacesContext} from the current thread by"," * {@link FacesContext#getCurrentInstance()}. This job is up to the caller."," *"," *
"," * Since OmniFaces 2.6,"," * all methods of {@link Faces} utility class which start with \"get\" or \"is\", and take no parameters, and return"," * either String
or boolean
, and are not related to response nor to session or flash (for"," * which already implicit EL objects #{session}
and #{flash}
exist), will be available as"," * properties of the implicit object #{faces}
. Examples are:"," *
"," * #{faces.development}"," * #{faces.serverInfo}"," * #{faces.ajaxRequest}"," * #{faces.requestBaseURL}"," * #{faces.requestURLWithQueryString}"," *"," *"," * @author Arjan Tijms"," * @author Bauke Scholtz"," * @see FacesLocal"," * @see Servlets"," * @see FacesELResolver"," */","public final class Faces {","","\t// Constructors ---------------------------------------------------------------------------------------------------","","\tprivate Faces() {","\t\t// Hide constructor.","\t}","","\t// Faces general ----------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the current faces context.","\t *
","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The current faces context.","\t * @see FacesContext#getCurrentInstance()","\t */","\tpublic static FacesContext getContext() {","\t\ttry {","\t\t\treturn FacesContext.getCurrentInstance();","\t\t}","\t\tcatch (NoClassDefFoundError canHappenWhenInvokedWithoutImpl) {","\t\t\treturn null;","\t\t}","\t}","","\t/**","\t * Returns the faces context that's stored in an ELContext.","\t *
","\t * Note that this only works for an ELContext that is created in the context of Faces.","\t *","\t * @param elContext the EL context to obtain the faces context from.","\t * @return the faces context that's stored in the given ELContext.","\t * @since 1.2","\t */","\tpublic static FacesContext getContext(ELContext elContext) {","\t\treturn (FacesContext) elContext.getContext(FacesContext.class);","\t}","","\t/**","\t * Sets the given faces context as current instance. Use this if you have a custom {@link FacesContextWrapper}","\t * which you'd like to (temporarily) use as the current instance of the faces context.","\t * @param context The faces context to be set as the current instance.","\t * @since 1.3","\t */","\tpublic static void setContext(FacesContext context) {","\t\tFacesContextSetter.setCurrentInstance(context);","\t}","","\t/**","\t * Inner class so that the protected {@link FacesContext#setCurrentInstance(FacesContext)} method can be invoked.","\t * @author Bauke Scholtz","\t */","\tprivate abstract static class FacesContextSetter extends FacesContext {","\t\tprotected static void setCurrentInstance(FacesContext context) {","\t\t\tFacesContext.setCurrentInstance(context);","\t\t}","\t}","","\t/**","\t * Returns true
when the current faces context is available (i.e. it is not null
).","\t * @return true
when the current faces context is available.","\t * @since 2.0","\t */","\tpublic static boolean hasContext() {","\t\treturn getContext() != null;","\t}","","\t/**","\t * Returns the current external context.","\t *
","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The current external context.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#getExternalContext()","\t */","\tpublic static ExternalContext getExternalContext() {","\t\treturn getContext().getExternalContext();","\t}","","\t/**","\t * Returns the application singleton.","\t *
","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The faces application singleton.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#getApplication()","\t */","\tpublic static Application getApplication() {","\t\treturn getContext().getApplication();","\t}","","\t/**","\t * Gets the Faces Application singleton from the FactoryFinder.","\t *
","\t * This method is an alternative for {@link Faces#getApplication()} for those situations where the","\t * {@link FacesContext} isn't available.","\t *","\t * @return The faces application singleton.","\t */","\tpublic static Application getApplicationFromFactory() {","\t\treturn ((ApplicationFactory) FactoryFinder.getFactory(APPLICATION_FACTORY)).getApplication();","\t}","","\t/**","\t * Returns the package of the currently loaded Faces implementation.","\t *
","\t * This is also available in EL as #{faces['package']}
.","\t * @return The package of the currently loaded Faces implementation.","\t * @since 3.14","\t */","\tpublic static Package getPackage() {","\t\treturn FacesLocal.getPackage(getContext());","\t}","","\t/**","\t * Returns the implementation information of currently loaded Faces implementation. E.g. \"Mojarra 2.1.7-FCS\".","\t *
","\t * This is also available in EL as #{faces.implInfo}
.","\t * @return The implementation information of currently loaded Faces implementation.","\t * @see Package#getImplementationTitle()","\t * @see Package#getImplementationVersion()","\t */","\tpublic static String getImplInfo() {","\t\treturn FacesLocal.getImplInfo(getContext());","\t}","","\t/**","\t * Returns the server information of currently running application server implementation.","\t *
","\t * This is also available in EL as #{faces.serverInfo}
.","\t * @return The server information of currently running application server implementation.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ServletContext#getServerInfo()","\t */","\tpublic static String getServerInfo() {","\t\treturn FacesLocal.getServerInfo(getContext());","\t}","","\t/**","\t * Returns the project stage. This will return the jakarta.faces.PROJECT_STAGE
context parameter in","\t * web.xml
.","\t * @return The project stage.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see Application#getProjectStage()","\t * @since 2.6","\t */","\tpublic static ProjectStage getProjectStage() {","\t\treturn FacesLocal.getProjectStage(getContext());","\t}","","\t/**","\t * Returns whether we're in development stage. This will be the case when the jakarta.faces.PROJECT_STAGE
","\t * context parameter in web.xml
is set to Development
.","\t *
","\t * This is also available in EL as #{faces.development}
.","\t * @return true
if we're in development stage, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see Application#getProjectStage()","\t */","\tpublic static boolean isDevelopment() {","\t\treturn FacesLocal.isDevelopment(getContext());","\t}","","\t/**","\t * Returns whether we're in system test stage. This will be the case when the jakarta.faces.PROJECT_STAGE
","\t * context parameter in web.xml
is set to SystemTest
.","\t *
","\t * This is also available in EL as #{faces.systemTest}
.","\t * @return true
if we're in system test stage, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see Application#getProjectStage()","\t * @since 2.6","\t */","\tpublic static boolean isSystemTest() {","\t\treturn FacesLocal.isSystemTest(getContext());","\t}","","\t/**","\t * Returns whether we're in production stage. This will be the case when the jakarta.faces.PROJECT_STAGE
","\t * context parameter in web.xml
is set to Production
.","\t *
","\t * This is also available in EL as #{faces.production}
.","\t * @return true
if we're in production stage, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see Application#getProjectStage()","\t * @since 2.6","\t */","\tpublic static boolean isProduction() {","\t\treturn FacesLocal.isProduction(getContext());","\t}","","\t/**","\t * Determines and returns the faces servlet mapping used in the current request. If Faces is prefix mapped (e.g.","\t * /faces/*
), then this returns the whole path, with a leading slash (e.g. /faces
). If Faces","\t * is suffix mapped (e.g. *.xhtml
), then this returns the whole extension (e.g. .xhtml
).","\t *
","\t * This is also available in EL as #{faces.mapping}
.","\t * @return The faces servlet mapping (without the wildcard).","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalStateException When mapping could not be determined.","\t * @see #getRequestPathInfo()","\t * @see #getRequestServletPath()","\t */","\tpublic static String getMapping() {","\t\treturn FacesLocal.getMapping(getContext());","\t}","","\t/**","\t * Returns whether the faces servlet mapping used in the current request is a prefix mapping.","\t *
","\t * This is also available in EL as #{faces.prefixMapping}
.","\t * @return true
if the faces servlet mapping used in the current request is a prefix mapping, otherwise","\t * false
.","\t * @see #getMapping()","\t * @see #isPrefixMapping(String)","\t */","\tpublic static boolean isPrefixMapping() {","\t\treturn isPrefixMapping(getMapping());","\t}","","\t/**","\t * Returns whether the given faces servlet mapping is a prefix mapping. Use this method in preference to","\t * {@link #isPrefixMapping()} when you already have obtained the mapping from {@link #getMapping()} so that the","\t * mapping won't be calculated twice.","\t * @param mapping The mapping to be tested.","\t * @return true
if the faces servlet mapping used in the current request is a prefix mapping, otherwise","\t * false
.","\t * @throws NullPointerException When mapping is null
.","\t */","\tpublic static boolean isPrefixMapping(String mapping) {","\t\treturn (mapping.charAt(0) == '/');","\t}","","\t/**","\t * Returns the current phase ID.","\t * @return The current phase ID.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#getCurrentPhaseId()","\t */","\tpublic static PhaseId getCurrentPhaseId() {","\t\treturn getContext().getCurrentPhaseId();","\t}","","\t/**","\t * Signals Faces that the validations phase of the current request has failed. This can be invoked in any other","\t * phase than the validations phase. The value can be read by {@link #isValidationFailed()} in Java and by","\t * #{facesContext.validationFailed}
in EL.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#validationFailed()","\t */","\tpublic static void validationFailed() {","\t\tgetContext().validationFailed();","\t}","","\t/**","\t * Returns whether the validations phase of the current request has failed.","\t *
","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * The current view ID is the view ID that's set for the view root that's associated with","\t * the current faces context.","\t *","\t * @return The {@link ViewDeclarationLanguage} associated with the \"current\" view ID.","\t * @throws NullPointerException When faces context is unavailable.","\t * @since 1.8","\t */","\tpublic static ViewDeclarationLanguage getViewDeclarationLanguage() {","\t\treturn FacesLocal.getViewDeclarationLanguage(getContext());","\t}","","\t/**","\t * Returns the {@link RenderKit} associated with the \"current\" view ID or view handler.","\t * ","\t * The current view ID is the view ID that's set for the view root that's associated with the current faces context.","\t * Or if there is none, then the current view handler will be assumed, which is the view handler that's associated","\t * with the requested view.","\t *","\t * @return The {@link RenderKit} associated with the \"current\" view ID or view handler.","\t * @throws NullPointerException When faces context is unavailable.","\t * @since 2.2","\t * @see UIViewRoot#getRenderKitId()","\t * @see ViewHandler#calculateRenderKitId(FacesContext)","\t */","\tpublic static RenderKit getRenderKit() {","\t\treturn FacesLocal.getRenderKit(getContext());","\t}","","\t/**","\t * Normalize the given path as a valid view ID based on the current mapping, if necessary.","\t * ","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The Facelet context.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalStateException When the Facelet context is not available.","\t * @see FaceletContext","\t * @since 1.1","\t */","\tpublic static FaceletContext getFaceletContext() {","\t\treturn FacesLocal.getFaceletContext(getContext());","\t}","","\t/**","\t * Returns the Facelet attribute value associated with the given name. This basically returns the value of the","\t * ","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The HTTP servlet request.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRequest()","\t */","\tpublic static HttpServletRequest getRequest() {","\t\treturn FacesLocal.getRequest(getContext());","\t}","","\t/**","\t * Returns whether the current request is an ajax request.","\t * ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The HTTP servlet response.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getResponse()","\t */","\tpublic static HttpServletResponse getResponse() {","\t\treturn FacesLocal.getResponse(getContext());","\t}","","\t/**","\t * Returns the HTTP response buffer size. If Facelets is used and the ","\t * You can use {@link String#format(String, Object...)} placeholder ","\t * You can use {@link String#format(String, Object...)} placeholder ","\t * This method does by design not work on ajax requests. It is not possible to return a \"permanent redirect\" via","\t * Faces ajax XML response.","\t * @param url The URL to redirect the current response to.","\t * @param paramValues The request parameter values which you'd like to put URL-encoded in the given URL.","\t * @throws NullPointerException When faces context is unavailable or given url is ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * This is also available in EL as ","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return The HTTP session.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getSession(boolean)","\t */","\tpublic static HttpSession getSession() {","\t\treturn FacesLocal.getSession(getContext());","\t}","","\t/**","\t * Returns the HTTP session and creates one if one doesn't exist and ","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @param create Whether or not to create a new session if one doesn't exist.","\t * @return The HTTP session.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getSession(boolean)","\t */","\tpublic static HttpSession getSession(boolean create) {","\t\treturn FacesLocal.getSession(getContext(), create);","\t}","","\t/**","\t * Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the","\t * servlet container and is implementation dependent.","\t * @return The HTTP session ID.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpSession#getId()","\t * @since 1.2","\t */","\tpublic static String getSessionId() {","\t\treturn FacesLocal.getSessionId(getContext());","\t}","","\t/**","\t * Invalidates the current HTTP session. So, any subsequent HTTP request will get a new one when necessary.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#invalidateSession()","\t */","\tpublic static void invalidateSession() {","\t\tFacesLocal.invalidateSession(getContext());","\t}","","\t/**","\t * Returns whether the HTTP session has already been created.","\t * @return ","\t * This is also available in EL as ","\t * Note that whenever you absolutely need this method to perform a general task, you might want to consider to","\t * submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general","\t * task.","\t * @return the servlet context.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getContext()","\t */","\tpublic static ServletContext getServletContext() {","\t\treturn FacesLocal.getServletContext(getContext());","\t}","","\t/**","\t * Returns the application initialization parameter map. This returns the parameter name-value pairs of all","\t * ","\t * Note that this will return ","\t * Also note that it wouldn't make sense to modify or create files in this location, as those changes would get lost","\t * anyway when the WAR is redeployed or even when the server is restarted. This is thus absolutely not a good","\t * location to store for example uploaded files.","\t * @param webContentPath The web content path to be converted to an absolute disk file system path.","\t * @return The absolute disk file system path representation of the given web content path.","\t * @throws NullPointerException When faces context is unavailable.","\t * @since 1.2","\t */","\tpublic static String getRealPath(String webContentPath) {","\t\treturn FacesLocal.getRealPath(getContext(), webContentPath);","\t}","","\t// Request scope --------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the request scope map.","\t * @return The request scope map.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRequestMap()","\t */","\tpublic static Map#{faces.validationFailed}
.","\t * @return true
if the validations phase of the current request has failed, otherwise","\t * false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#isValidationFailed()","\t */","\tpublic static boolean isValidationFailed() {","\t\treturn getContext().isValidationFailed();","\t}","","\t/**","\t * Returns the current EL context.","\t * @return The current EL context.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#getELContext()","\t * @since 2.0","\t */","\tpublic static ELContext getELContext() {","\t\treturn getContext().getELContext();","\t}","","\t/**","\t * Programmatically evaluate the given EL expression and return the evaluated value.","\t * @param T
is of wrong type.","\t * @see Application#evaluateExpressionGet(FacesContext, String, Class)","\t */","\tpublic static T
is of wrong type.","\t * @see Application#getELResolver()","\t * @see ELResolver#getValue(ELContext, Object, Object)","\t * @since 2.1","\t */","\tpublic static T
is of wrong type.","\t * @see FacesContext#getAttributes()","\t * @since 1.3","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getRequestMap()","\t * @since 3.1","\t */","\tpublic static null
if there is no view.","\t * #{faces.viewId}
, although #{view.viewId}
could be used.","\t * @return The ID of the current view root, or null
if there is no view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see UIViewRoot#getViewId()","\t */","\tpublic static String getViewId() {","\t\treturn FacesLocal.getViewId(getContext());","\t}","","\t/**","\t * Returns the ID of the current view root with view and hash parameters.","\t * #{faces.viewIdWithParameters}
.","\t * @return The ID of the current view root with view and hash parameters.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see UIViewRoot#getViewId()","\t * @see ViewMetadata#getViewParameters(UIViewRoot)","\t * @see Faces#getHashParameters()","\t * @since 2.5","\t */","\tpublic static String getViewIdWithParameters() {","\t\treturn FacesLocal.getViewIdWithParameters(getContext());","\t}","","\t/**","\t * Returns the base name of the current view, without extension, or null
if there is no view.","\t * E.g. if the view ID is /path/to/some.xhtml
, then this will return some
.","\t * #{faces.viewName}
.","\t * @return The base name of the current view, without extension, or null
if there is no view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see UIViewRoot#getViewId()","\t * @since 2.3","\t */","\tpublic static String getViewName() {","\t\treturn FacesLocal.getViewName(getContext());","\t}","","\t/**","\t * Returns the {@link ViewDeclarationLanguage} associated with the \"current\" view ID.","\t * ","\t *
","\t * @param path The path to be normalized as a valid view ID based on the current mapping.","\t * @return The path as a valid view ID.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see #getMapping()","\t * @see #isPrefixMapping(String)","\t */","\tpublic static String normalizeViewId(String path) {","\t\treturn FacesLocal.normalizeViewId(getContext(), path);","\t}","","\t/**","\t * Returns the view parameters of the current view, or an empty collection if there is no view.","\t * @return The view parameters of the current view, or an empty collection if there is no view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ViewMetadata#getViewParameters(UIViewRoot)","\t */","\tpublic static Collectionnull
if there is none.","\t * This is the part after the #
in the request URL as the enduser sees in browser address bar.","\t * This works only if the hash parameters are via <o:hashParam>
registered in the view.","\t * @return The hash query string of the current view, or null
if there is none.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HashParam","\t * @since 3.2","\t */","\tpublic static String getHashQueryString() {","\t\treturn FacesLocal.getHashQueryString(getContext());","\t}","","\t/**","\t * Returns the script parameters of the current view, or an empty collection if there is no view.","\t * @return The script parameters of the current view, or an empty collection if there is no view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ScriptParam","\t * @since 3.6","\t */","\tpublic static CollectionT
is of wrong type.","\t * @see ViewDeclarationLanguage#getViewMetadata(FacesContext, String)","\t * @since 1.4","\t */","\tpublic static T
is of wrong type.","\t * @see UIViewRoot#getAttributes()","\t * @since 1.4","\t */","\tpublic static null
if there is none.","\t * @return The default locale, or null
if there is none.","\t * @see Application#getDefaultLocale()","\t */","\tpublic static Locale getDefaultLocale() {","\t\treturn FacesLocal.getDefaultLocale(getContext());","\t}","","\t/**","\t * Returns an unordered list of all supported locales on this application, with the default locale as the first","\t * item, if any. This will return an empty list if there are no locales definied in faces-config.xml
.","\t * @return An unordered list of all supported locales on this application, with the default locale as the first","\t * item, if any. If you need an ordered list, use {@link FacesConfigXml#getSupportedLocales()} instead.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see Application#getDefaultLocale()","\t * @see Application#getSupportedLocales()","\t */","\tpublic static Listnull
). This can happen if the","\t * method is called at the wrong moment in the Faces lifecycle, e.g. before the view has been restored/created.","\t * @see UIViewRoot#setLocale(Locale)","\t * @since 1.2","\t */","\tpublic static void setLocale(Locale locale) {","\t\tFacesLocal.setLocale(getContext(), locale);","\t}","","\t/**","\t * Returns the application message bundle as identified by <message-bundle>
in","\t * faces-config.xml
. The instance is already localized via {@link Faces#getLocale()}. If there is no","\t * <message-bundle>
, then this method just returns null
.","\t * @return The message bundle as identified by <message-bundle>
in faces-config.xml
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws MissingResourceException When the <message-bundle>
in faces-config.xml
","\t * does not refer an existing resource in the classpath.","\t * @see Application#getMessageBundle()","\t * @since 2.0","\t */","\tpublic static ResourceBundle getMessageBundle() {","\t\treturn FacesLocal.getMessageBundle(getContext());","\t}","","\t/**","\t * Returns the application resource bundle as identified by the given <var>
of the","\t * <resource-bundle>
in faces-config.xml
. If there is no","\t * <resource-bundle>
with the given <var>
, then this method just returns","\t * null
.","\t * @param var The value of the <var>
which identifies the <resource-bundle>
in","\t * faces-config.xml
.","\t * @return The application resource bundle as identified by the given <var>
of the","\t * <resource-bundle>
in faces-config.xml
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws MissingResourceException When the <resource-bundle>
as identified by the given","\t * <var>
in faces-config.xml
does not refer an existing resource in the classpath.","\t * @see Application#getResourceBundle(FacesContext, String)","\t * @since 2.0","\t */","\tpublic static ResourceBundle getResourceBundle(String var) {","\t\treturn FacesLocal.getResourceBundle(getContext(), var);","\t}","","\t/**","\t * Returns all application resource bundles registered as <resource-bundle>
in","\t * faces-config.xml
. If there are no resource bundles registered, then this method just returns an","\t * empty map.","\t * @return all application resource bundles registered as <resource-bundle>
in","\t * faces-config.xml
.","\t * <base-name>
of the <resource-bundle>
in faces-config.xml
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws MissingResourceException When the <resource-bundle>
in faces-config.xml
","\t * does not refer an existing resource in the classpath.","\t * @see Application#getResourceBundle(FacesContext, String)","\t * @since 2.1","\t */","\tpublic static Mapfaces-config.xml
.","\t * If the string is missing, then this method returns ???key???
.","\t * @param key The bundle key.","\t * @return a string for the given key searching declared resource bundles, order by declaration in","\t * faces-config.xml
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @since 2.1","\t */","\tpublic static String getBundleString(String key) {","\t\treturn FacesLocal.getBundleString(getContext(), key);","\t}","","\t/**","\t * Perform the Faces navigation to the given outcome.","\t * @param outcome The navigation outcome.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see Application#getNavigationHandler()","\t * @see NavigationHandler#handleNavigation(FacesContext, String, String)","\t */","\tpublic static void navigate(String outcome) {","\t\tFacesLocal.navigate(getContext(), outcome);","\t}","","\t/**","\t * Returns the concrete domain-relative URL to the current view with the given params URL-encoded in the query","\t * string and optionally include view parameters as well. This URL can ultimately be used as redirect URL, or in","\t * <form action>
, or in <a href>
. Any parameter with an empty name or value","\t * will be skipped. To skip empty view parameters as well, use <o:viewParam>
instead.","\t * @param params The parameters to be URL-encoded in the query string. Can be null
.","\t * @param includeViewParams Whether the view parameters of the current view should be included as well.","\t * @return The concrete domain-relative URL to the current view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalStateException When there is no view (i.e. when it is null
). This can happen if the","\t * method is called at the wrong moment in the Faces lifecycle, e.g. before the view has been restored/created.","\t * @see ViewHandler#getBookmarkableURL(FacesContext, String, Map, boolean)","\t * @since 1.6","\t */","\tpublic static String getBookmarkableURL(Map<form action>
, or in <a href>
. Any parameter with an empty name or value","\t * will be skipped. To skip empty view parameters as well, use <o:viewParam>
instead.","\t * @param viewId The view ID to create the bookmarkable URL for.","\t * @param params The parameters to be URL-encoded in the query string. Can be null
.","\t * @param includeViewParams Whether the view parameters of the current view which are also declared in the target","\t * view should be included as well. Note thus that this does not include the view parameters which are not declared","\t * in the target view!","\t * @return The concrete domain-relative URL to the target view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ViewHandler#getBookmarkableURL(FacesContext, String, Map, boolean)","\t * @since 1.6","\t */","\tpublic static String getBookmarkableURL(String viewId, Map<form action>
, or in <a href>
. Any parameter with an empty name or value","\t * will be skipped. To skip empty view parameters as well, use <o:viewParam>
instead.","\t * @param params The parameters to be URL-encoded in the query string. Can be null
.","\t * @param includeViewParams Whether the view parameters of the current view should be included as well.","\t * @return The concrete domain-relative URL to the current view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalStateException When there is no view (i.e. when it is null
). This can happen if the","\t * method is called at the wrong moment in the Faces lifecycle, e.g. before the view has been restored/created.","\t * @see ViewHandler#getBookmarkableURL(FacesContext, String, Map, boolean)","\t * @since 1.7","\t */","\tpublic static String getBookmarkableURL(Collection extends ParamHolder>> params, boolean includeViewParams) {","\t\treturn FacesLocal.getBookmarkableURL(getContext(), params, includeViewParams);","\t}","","\t/**","\t * Returns the concrete domain-relative URL to the given view with the given params URL-encoded in the query","\t * string and optionally include view parameters as well. This URL can ultimately be used as redirect URL, or in","\t * <form action>
, or in <a href>
. Any parameter with an empty name or value","\t * will be skipped. To skip empty view parameters as well, use <o:viewParam>
instead.","\t * @param viewId The view ID to create the bookmarkable URL for.","\t * @param params The parameters to be URL-encoded in the query string. Can be null
.","\t * @param includeViewParams Whether the view parameters of the current view which are also declared in the target","\t * view should be included as well. Note thus that this does not include the view parameters which are not declared","\t * in the target view!","\t * @return The concrete domain-relative URL to the target view.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ViewHandler#getBookmarkableURL(FacesContext, String, Map, boolean)","\t * @since 1.7","\t */","\tpublic static String getBookmarkableURL(String viewId, Collection extends ParamHolder>> params, boolean includeViewParams) {","\t\treturn FacesLocal.getBookmarkableURL(getContext(), viewId, params, includeViewParams);","\t}","","\t// Facelets -------------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the Facelet context.","\t * <ui:param>
which is been declared inside the Facelet file, or is been passed into the Facelet","\t * file by e.g. an <ui:include>
.","\t * @param T
is of wrong type.","\t * @see FaceletContext#getAttribute(String)","\t * @since 1.1","\t */","\tpublic static <ui:param>
which is been declared inside the Facelet file, or is been passed into the Facelet","\t * file by e.g. an <ui:include>
.","\t * @param name The Facelet attribute name.","\t * @param value The Facelet attribute value.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalStateException When the Facelet context is not available.","\t * @see FaceletContext#setAttribute(String, Object)","\t * @since 1.1","\t */","\tpublic static void setFaceletAttribute(String name, Object value) {","\t\tFacesLocal.setFaceletAttribute(getContext(), name, value);","\t}","","\t// HTTP request ---------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the HTTP servlet request.","\t * #{faces.ajaxRequest}
.","\t * @return true
for an ajax request, false
for a non-ajax (synchronous) request.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see PartialViewContext#isAjaxRequest()","\t */","\tpublic static boolean isAjaxRequest() {","\t\treturn FacesLocal.isAjaxRequest(getContext());","\t}","","\t/**","\t * Returns whether the current request is an ajax request with partial rendering. That is, when it's an ajax request","\t * without render=\"@all\"
.","\t * #{faces.ajaxRequestWithPartialRendering}
.","\t * @return true
for an ajax request with partial rendering, false
an ajax request with","\t * render=\"@all\"
or a non-ajax (synchronous) request.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see PartialViewContext#isAjaxRequest()","\t * @see PartialViewContext#isRenderAll()","\t * @since 2.3","\t */","\tpublic static boolean isAjaxRequestWithPartialRendering() {","\t\treturn FacesLocal.isAjaxRequestWithPartialRendering(getContext());","\t}","","\t/**","\t * Returns whether the current request is a postback. This not only delegates to {@link FacesContext#isPostback()}","\t * which checks the presence of jakarta.faces.ViewState
request parameter, but this also explicitly","\t * checks the HTTP request method. So this should exclude GET requests having a jakarta.faces.ViewState
","\t * request parameter in query string.","\t * #{faces.postback}
.","\t * @return true
for a postback, false
for a non-postback (GET) request.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#isPostback()","\t */","\tpublic static boolean isPostback() {","\t\treturn FacesLocal.isPostback(getContext());","\t}","","\t/**","\t * Returns the HTTP request parameter map.","\t * @return The HTTP request parameter map.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRequestParameterMap()","\t */","\tpublic static MapforClass
on the given type.","\t * Note that empty strings are already implicitly converted to null
.","\t * @param forClass
type.","\t * @return The HTTP request parameter value associated with the given name and implicitly converted to given type.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ConverterException When conversion fails.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getRequestParameterMap()","\t * @see Faces#createConverter(Class)","\t * @since 2.6","\t */","\tpublic static null
.","\t * @param null
.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getRequestParameterMap()","\t * @since 3.10","\t */","\tpublic static null
.","\t * @param T
is of wrong type.","\t * @throws NullPointerException When faces context is unavailable or given converter or supplier is null
.","\t * @see ExternalContext#getRequestParameterMap()","\t * @since 3.10","\t */","\tpublic static forClass
on the given type.","\t * @param forClass
type.","\t * @return The HTTP request parameter values associated with the given name and implicitly convert it to given type.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ConverterException When conversion fails.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getRequestParameterValuesMap()","\t * @see Faces#createConverter(Class)","\t * @since 2.6","\t */","\tpublic static multipart/form-data
. If there are","\t * no parts, an empty collection is returned.","\t * @return all HTTP request parts.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws FacesException Whenever something fails at servlet or I/O level. The caller should preferably not catch","\t * it, but just let it go. The servletcontainer will handle it.","\t * @see HttpServletRequest#getParts()","\t * @since 2.5","\t */","\tpublic static Collectionmultipart/form-data
. If there are no parts, an empty collection is returned.","\t * @param name The HTTP request part name.","\t * @return All HTTP request parts associated with the given name.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws FacesException Whenever something fails at servlet or I/O level. The caller should preferably not catch","\t * it, but just let it go. The servletcontainer will handle it.","\t * @see HttpServletRequest#getParts()","\t * @since 2.5","\t */","\tpublic static Collection#{faces.requestContextPath}
.","\t * @return The HTTP request context path.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRequestContextPath()","\t */","\tpublic static String getRequestContextPath() {","\t\treturn FacesLocal.getRequestContextPath(getContext());","\t}","","\t/**","\t * Returns the HTTP request servlet path. If Faces is prefix mapped (e.g. /faces/*
), then this returns","\t * the whole prefix mapping (e.g. /faces
). If Faces is suffix mapped (e.g. *.xhtml
), then","\t * this returns the whole part after the context path, with a leading slash.","\t * #{faces.requestServletPath}
.","\t * @return The HTTP request servlet path.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRequestServletPath()","\t */","\tpublic static String getRequestServletPath() {","\t\treturn FacesLocal.getRequestServletPath(getContext());","\t}","","\t/**","\t * Returns the HTTP request path info, taking into account whether FacesViews is used with MultiViews enabled.","\t * If the resource is prefix mapped (e.g. /faces/*
), then this returns the whole part after the prefix","\t * mapping, with a leading slash. If the resource is suffix mapped (e.g. *.xhtml
), then this returns","\t * null
. If MultiViews is enabled, then this returns the part after the mapped view, if any.","\t * #{faces.requestPathInfo}
.","\t * @return The HTTP request path info.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRequestPathInfo()","\t * @see FacesViews#FACES_VIEWS_ORIGINAL_PATH_INFO","\t */","\tpublic static String getRequestPathInfo() {","\t\treturn FacesLocal.getRequestPathInfo(getContext());","\t}","","\t/**","\t * Returns the HTTP request hostname. This is the entire domain, without any scheme and slashes. Noted should be","\t * that this value is extracted from the request URL, not from {@link HttpServletRequest#getServerName()} as its","\t * outcome can be influenced by proxies.","\t * #{faces.requestHostName}
.","\t * @return The HTTP request hostname.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalArgumentException When the URL is malformed. This is however unexpected as the request would","\t * otherwise not have hit the server at all.","\t * @see HttpServletRequest#getRequestURL()","\t * @since 1.6","\t */","\tpublic static String getRequestHostname() {","\t\treturn FacesLocal.getRequestHostname(getContext());","\t}","","\t/**","\t * Returns the HTTP request base URL. This is the URL from the scheme, domain until with context path, including","\t * the trailing slash. This is the value you could use in HTML <base>
tag.","\t * #{faces.requestBaseURL}
.","\t * @return The HTTP request base URL.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestURL()","\t * @see HttpServletRequest#getRequestURI()","\t * @see HttpServletRequest#getContextPath()","\t */","\tpublic static String getRequestBaseURL() {","\t\treturn FacesLocal.getRequestBaseURL(getContext());","\t}","","\t/**","\t * Returns the HTTP request domain URL. This is the URL with the scheme and domain, without any trailing slash.","\t * #{faces.requestDomainURL}
.","\t * @return The HTTP request domain URL.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestURL()","\t * @see HttpServletRequest#getRequestURI()","\t * @since 1.1","\t */","\tpublic static String getRequestDomainURL() {","\t\treturn FacesLocal.getRequestDomainURL(getContext());","\t}","","\t/**","\t * Returns the HTTP request URL. This is the full request URL as the enduser sees in browser address bar. This does","\t * not include the request query string.","\t * #{faces.requestURL}
.","\t * @return The HTTP request URL.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestURL()","\t * @since 1.1","\t */","\tpublic static String getRequestURL() {","\t\treturn FacesLocal.getRequestURL(getContext());","\t}","","\t/**","\t * Returns the HTTP request URI. This is the part after the domain in the request URL, including the leading slash.","\t * This does not include the request query string.","\t * #{faces.requestURI}
.","\t * @return The HTTP request URI.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestURI()","\t * @since 1.1","\t */","\tpublic static String getRequestURI() {","\t\treturn FacesLocal.getRequestURI(getContext());","\t}","","\t/**","\t * Returns the HTTP request query string. This is the part after the ?
in the request URL as the","\t * enduser sees in browser address bar.","\t * #{faces.requestQueryString}
.","\t * @return The HTTP request query string.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getQueryString()","\t * @since 1.1","\t */","\tpublic static String getRequestQueryString() {","\t\treturn FacesLocal.getRequestQueryString(getContext());","\t}","","\t/**","\t * Returns the HTTP request query string as parameter values map. Note this method returns only","\t * the request URL (GET) parameters, as opposed to {@link #getRequestParameterValuesMap()}, which contains both","\t * the request URL (GET) parameters and the request body (POST) parameters. This is ready for usage in among","\t * others {@link ViewHandler#getBookmarkableURL(FacesContext, String, Map, boolean)}.","\t * @return The HTTP request query string as parameter values map.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getQueryString()","\t * @since 1.6","\t */","\tpublic static Map#{faces.requestURLWithQueryString}
.","\t * @return The HTTP request URL with query string.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestURL()","\t * @see HttpServletRequest#getQueryString()","\t * @since 1.5","\t */","\tpublic static String getRequestURLWithQueryString() {","\t\treturn FacesLocal.getRequestURLWithQueryString(getContext());","\t}","","\t/**","\t * Returns the HTTP request URI with query string. This is the part after the domain in the request URL, including","\t * the leading slash and the request query string.","\t * #{faces.requestURIWithQueryString}
.","\t * @return The HTTP request URI with query string.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestURI()","\t * @see HttpServletRequest#getQueryString()","\t * @since 1.6","\t */","\tpublic static String getRequestURIWithQueryString() {","\t\treturn FacesLocal.getRequestURIWithQueryString(getContext());","\t}","","\t/**","\t * Returns the Internet Protocol (IP) address of the client that sent the request. This will first check the","\t * X-Forwarded-For
request header and if it's present, then return its first IP address, else just","\t * return {@link HttpServletRequest#getRemoteAddr()} unmodified.","\t * #{faces.remoteAddr}
.","\t * @return The IP address of the client.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRemoteAddr()","\t * @since 1.2","\t */","\tpublic static String getRemoteAddr() {","\t\treturn FacesLocal.getRemoteAddr(getContext());","\t}","","\t/**","\t * Returns the User-Agent string of the client.","\t * #{faces.userAgent}
.","\t * @return The User-Agent string of the client.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getHeader(String)","\t * @since 3.2","\t */","\tpublic static String getUserAgent() {","\t\treturn FacesLocal.getUserAgent(getContext());","\t}","","\t/**","\t * Returns the referrer of the request.","\t * #{faces.referrer}
.","\t * @return The referrer of the request.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getHeader(String)","\t * @since 3.10","\t */","\tpublic static String getReferrer() {","\t\treturn FacesLocal.getReferrer(getContext());","\t}","","\t/**","\t * Returns true
if connection is secure, false
otherwise. This method will first check if","\t * {@link HttpServletRequest#isSecure()} returns true
, and if not true
, check if the","\t * X-Forwarded-Proto
is present and equals to https
.","\t * @return true
if connection is secure, false
otherwise.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#isSecure()","\t * @since 3.0","\t */","\tpublic static boolean isRequestSecure() {","\t\treturn FacesLocal.isRequestSecure(getContext());","\t}","","\t// HTTP response --------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the HTTP servlet response.","\t * jakarta.faces.FACELETS_BUFFER_SIZE
","\t * context parameter is been set, then it's the context parameter value which will be returned. Otherwise it","\t * returns the implementation independent default value, which is 1024 in Mojarra.","\t * @return The HTTP response buffer size.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getResponseBufferSize()","\t * @since 1.2","\t */","\tpublic static int getResponseBufferSize() {","\t\treturn FacesLocal.getResponseBufferSize(getContext());","\t}","","\t/**","\t * Returns the HTTP response character encoding.","\t * @return The HTTP response character encoding.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getResponseCharacterEncoding()","\t * @since 1.2","\t */","\tpublic static String getResponseCharacterEncoding() {","\t\treturn FacesLocal.getResponseCharacterEncoding(getContext());","\t}","","\t/**","\t * Sets the HTTP response status code. You can use the constant field values of {@link HttpServletResponse} for","\t * this. For example, Faces.setResponseStatus(HttpServletResponse.SC_BAD_REQUEST)
.","\t * @param status The HTTP status code to be set on the current response.","\t * @throws NullPointerException When faces context is unavailable.","\t * @since 1.6","\t */","\tpublic static void setResponseStatus(int status) {","\t\tFacesLocal.setResponseStatus(getContext(), status);","\t}","","\t/**","\t * Sends a temporary (302) redirect to the given URL. If the given URL does not start with http://
,","\t * https://
or /
, then the request context path will be prepended, otherwise it will be","\t * the unmodified redirect URL. So, when redirecting to another page in the same web application, always specify the","\t * full path from the context root on (which in turn does not need to start with /
).","\t * ","\t * Faces.redirect(\"other.xhtml\");","\t *
","\t * %s
in the redirect URL to represent","\t * placeholders for any request parameter values which needs to be URL-encoded. Here's a concrete example:","\t * ","\t * Faces.redirect(\"other.xhtml?foo=%s&bar=%s\", foo, bar);","\t *
","\t * @param url The URL to redirect the current response to.","\t * @param paramValues The request parameter values which you'd like to put URL-encoded in the given URL.","\t * @throws NullPointerException When faces context is unavailable or given url is null
.","\t * @throws UncheckedIOException When HTTP response is not available anymore.","\t * @see ExternalContext#redirect(String)","\t */","\tpublic static void redirect(String url, Object... paramValues) {","\t\tFacesLocal.redirect(getContext(), url, paramValues);","\t}","","\t/**","\t * Sends a permanent (301) redirect to the given URL. If the given URL does not start with http://
,","\t * https://
or /
, then the request context path will be prepended, otherwise it will be","\t * the unmodified redirect URL. So, when redirecting to another page in the same web application, always specify the","\t * full path from the context root on (which in turn does not need to start with /
).","\t * ","\t * Faces.redirectPermanent(\"other.xhtml\");","\t *
","\t * %s
in the redirect URL to represent","\t * placeholders for any request parameter values which needs to be URL-encoded. Here's a concrete example:","\t * ","\t * Faces.redirectPermanent(\"other.xhtml?foo=%s&bar=%s\", foo, bar);","\t *
","\t * null
.","\t * @see ExternalContext#setResponseStatus(int)","\t * @see ExternalContext#setResponseHeader(String, String)","\t */","\tpublic static void redirectPermanent(String url, Object... paramValues) {","\t\tFacesLocal.redirectPermanent(getContext(), url, paramValues);","\t}","","\t/**","\t * Refresh the current page by a GET request. This basically sends a temporary (302) redirect to current request","\t * URI, without query string.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UncheckedIOException When HTTP response is not available anymore.","\t * @see ExternalContext#redirect(String)","\t * @see HttpServletRequest#getRequestURI()","\t * @since 2.2","\t */","\tpublic static void refresh() {","\t\tFacesLocal.refresh(getContext());","\t}","","\t/**","\t * Refresh the current page by a GET request, maintaining the query string. This basically sends a temporary (302)","\t * redirect to current request URI, with the current query string.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UncheckedIOException When HTTP response is not available anymore.","\t * @see ExternalContext#redirect(String)","\t * @see HttpServletRequest#getRequestURI()","\t * @see HttpServletRequest#getQueryString()","\t * @since 2.2","\t */","\tpublic static void refreshWithQueryString() {","\t\tFacesLocal.refreshWithQueryString(getContext());","\t}","","\t/**","\t * Sends a HTTP response error with the given status and message. This will end up in either a custom","\t * <error-page>
whose <error-code>
matches the given status, or in a servlet","\t * container specific default error page if there is none. The message will be available in the error page as a","\t * request attribute with name jakarta.servlet.error.message
. The {@link FacesContext#responseComplete()}","\t * will implicitly be called after sending the error.","\t * @param status The HTTP response status which is supposed to be in the range 4nn-5nn. You can use the constant","\t * field values of {@link HttpServletResponse} for this.","\t * @param message The message which is supposed to be available in the error page.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UncheckedIOException When HTTP response is not available anymore.","\t * @see ExternalContext#responseSendError(int, String)","\t */","\tpublic static void responseSendError(int status, String message) {","\t\tFacesLocal.responseSendError(getContext(), status, message);","\t}","","\t/**","\t * Add a header with given name and value to the HTTP response.","\t * @param name The header name.","\t * @param value The header value.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#addResponseHeader(String, String)","\t */","\tpublic static void addResponseHeader(String name, String value) {","\t\tFacesLocal.addResponseHeader(getContext(), name, value);","\t}","","\t/**","\t * Returns whether the response is already committed. That is, when the response headers and a part of the response","\t * body has already been sent to the client. This is usually a point of no return and you can't change the response","\t * anymore.","\t * @return true
if the response is already committed, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#isResponseCommitted()","\t * @since 1.1","\t */","\tpublic static boolean isResponseCommitted() {","\t\treturn FacesLocal.isResponseCommitted(getContext());","\t}","","\t/**","\t * Resets the current response. This will clear any headers which are been set and any data which is written to","\t * the response buffer which isn't committed yet.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws IllegalStateException When the response is already committed.","\t * @see ExternalContext#responseReset()","\t * @since 1.1","\t */","\tpublic static void responseReset() {","\t\tFacesLocal.responseReset(getContext());","\t}","","\t/**","\t * Signals Faces that, as soon as the current phase of the lifecycle has been completed, control should be passed to","\t * the Render Response phase, bypassing any phases that have not been executed yet.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#renderResponse()","\t * @since 1.4","\t */","\tpublic static void renderResponse() {","\t\tgetContext().renderResponse();","\t}","","\t/**","\t * Returns true
if we're currently in the render response phase. This explicitly checks the current","\t * phase ID instead of {@link FacesContext#getRenderResponse()} as the latter may unexpectedly return false during","\t * a GET request when <f:viewParam>
is been used.","\t * #{faces.renderResponse}
.","\t * @return true
if we're currently in the render response phase.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#getCurrentPhaseId()","\t * @since 1.4","\t */","\tpublic static boolean isRenderResponse() {","\t\treturn FacesLocal.isRenderResponse(getContext());","\t}","","\t/**","\t * Signals Faces that the response for this request has already been generated (such as providing a file download),","\t * and that the lifecycle should be terminated as soon as the current phase is completed.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#responseComplete()","\t * @since 1.4","\t */","\tpublic static void responseComplete() {","\t\tgetContext().responseComplete();","\t}","","\t/**","\t * Returns true
if the {@link FacesContext#responseComplete()} has been called.","\t * @return true
if the {@link FacesContext#responseComplete()} has been called.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see FacesContext#responseComplete()","\t * @since 1.4","\t */","\tpublic static boolean isResponseComplete() {","\t\treturn getContext().getResponseComplete();","\t}","","\t// FORM based authentication --------------------------------------------------------------------------------------","","\t/**","\t * Perform programmatic login for container managed FORM based authentication. Note that configuration is container","\t * specific and unrelated to Faces. Refer the documentation of the servletcontainer using the keyword \"realm\".","\t * @param username The login username.","\t * @param password The login password.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ServletException When the login is invalid, or when container managed FORM based authentication is not","\t * enabled.","\t * @see HttpServletRequest#login(String, String)","\t */","\tpublic static void login(String username, String password) throws ServletException {","\t\tFacesLocal.login(getContext(), username, password);","\t}","","\t/**","\t * Trigger the default container managed authentication mechanism on the current request. It expects the username","\t * and password being available as predefinied request parameters on the current request and/or a custom JASPIC","\t * implementation.","\t * @return true
if the authentication was successful, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ServletException When the authentication has failed. The caller is responsible for handling it.","\t * @throws UncheckedIOException When HTTP request or response is not available anymore.","\t * @see HttpServletRequest#authenticate(HttpServletResponse)","\t * @since 1.4","\t */","\tpublic static boolean authenticate() throws ServletException {","\t\treturn FacesLocal.authenticate(getContext());","\t}","","\t/**","\t * Returns whether the current request is authenticated, i.e. it has a logged-in user.","\t * #{faces.authenticated}
.","\t * @return true
if the current request is authenticated, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRemoteUser()","\t * @since 4.3","\t */","\tpublic static boolean isAuthenticated() {","\t\treturn FacesLocal.isAuthenticated(getContext());","\t}","","\t/**","\t * Perform programmatic logout for container managed FORM based authentication. Note that this basically removes","\t * the user principal from the session. It's however better practice to just invalidate the session altogether,","\t * which will implicitly also remove the user principal. Just invoke {@link #invalidateSession()} instead. Note","\t * that the user principal is still present in the response of the current request, it's therefore recommend to","\t * send a redirect after {@link #logout()} or {@link #invalidateSession()}. You can use","\t * {@link #redirect(String, Object...)} for this.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ServletException When the logout has failed.","\t * @see HttpServletRequest#logout()","\t */","\tpublic static void logout() throws ServletException {","\t\tFacesLocal.logout(getContext());","\t}","","\t/**","\t * Returns the name of the logged-in user for container managed FORM based authentication, if any.","\t * #{faces.remoteUser}
.","\t * @return The name of the logged-in user for container managed FORM based authentication, if any.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getRemoteUser()","\t */","\tpublic static String getRemoteUser() {","\t\treturn FacesLocal.getRemoteUser(getContext());","\t}","","\t/**","\t * Returns whether the currently logged-in user has the given role.","\t * @param role The role to be checked on the currently logged-in user.","\t * @return true
if the currently logged-in user has the given role, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#isUserInRole(String)","\t */","\tpublic static boolean isUserInRole(String role) {","\t\treturn FacesLocal.isUserInRole(getContext(), role);","\t}","","\t// HTTP cookies ---------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the value of the HTTP request cookie associated with the given name. The value is implicitly URL-decoded","\t * with a charset of UTF-8.","\t * @param name The HTTP request cookie name.","\t * @return The value of the HTTP request cookie associated with the given name.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UnsupportedOperationException When this platform does not support UTF-8.","\t * @see ExternalContext#getRequestCookieMap()","\t */","\tpublic static String getRequestCookie(String name) {","\t\treturn FacesLocal.getRequestCookie(getContext(), name);","\t}","","\t/**","\t * Add a cookie with given name, value and maxage to the HTTP response.","\t * The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored.","\t * The cookie will implicitly be set in the domain and path of the current request URL.","\t * The cookie will implicitly be set to HttpOnly as JavaScript is not supposed to manipulate server-created cookies.","\t * The cookie will implicitly be set to secure when the current request is a HTTPS request.","\t * @param name The cookie name.","\t * @param value The cookie value.","\t * @param maxAge The maximum age of the cookie, in seconds. If this is 0
, then the cookie will be","\t * removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is","\t * -1
then the cookie will become a session cookie and thus live as long as the established HTTP","\t * session.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UnsupportedOperationException When this platform does not support UTF-8.","\t * @see ExternalContext#addResponseCookie(String, String, Map)","\t * @since 1.8","\t */","\tpublic static void addResponseCookie(String name, String value, int maxAge) {","\t\tFacesLocal.addResponseCookie(getContext(), name, value, maxAge);","\t}","","\t/**","\t * Add a cookie with given name, value, path and maxage to the HTTP response.","\t * The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored.","\t * The cookie will implicitly be set in the domain of the current request URL.","\t * The cookie will implicitly be set to HttpOnly as JavaScript is not supposed to manipulate server-created cookies.","\t * The cookie will implicitly be set to secure when the current request is a HTTPS request.","\t * @param name The cookie name.","\t * @param value The cookie value.","\t * @param path The cookie path. If this is /
, then the cookie is available in all pages of the webapp.","\t * If this is /somespecificpath
, then the cookie is only available in pages under the specified path.","\t * @param maxAge The maximum age of the cookie, in seconds. If this is 0
, then the cookie will be","\t * removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is","\t * -1
then the cookie will become a session cookie and thus live as long as the established HTTP","\t * session.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UnsupportedOperationException When this platform does not support UTF-8.","\t * @see ExternalContext#addResponseCookie(String, String, Map)","\t */","\tpublic static void addResponseCookie(String name, String value, String path, int maxAge) {","\t\tFacesLocal.addResponseCookie(getContext(), name, value, path, maxAge);","\t}","","\t/**","\t * Add a cookie with given name, value, domain, path and maxage to the HTTP response.","\t * The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored.","\t * The cookie will implicitly be set to HttpOnly as JavaScript is not supposed to manipulate server-created cookies.","\t * The cookie will implicitly be set to secure when the current request is a HTTPS request.","\t * @param name The cookie name.","\t * @param value The cookie value.","\t * @param domain The cookie domain. You can use .example.com
(with a leading period) if you'd like the","\t * cookie to be available to all subdomains of the domain. Note that you cannot set it to a different domain.","\t * Defaults to {@link #getRequestHostname()} when null
.","\t * @param path The cookie path. If this is /
, then the cookie is available in all pages of the webapp.","\t * If this is /somespecificpath
, then the cookie is only available in pages under the specified path.","\t * @param maxAge The maximum age of the cookie, in seconds. If this is 0
, then the cookie will be","\t * removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is","\t * -1
then the cookie will become a session cookie and thus live as long as the established HTTP","\t * session.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UnsupportedOperationException When this platform does not support UTF-8.","\t * @see ExternalContext#addResponseCookie(String, String, Map)","\t * @since 1.8","\t */","\tpublic static void addResponseCookie(String name, String value, String domain, String path, int maxAge) {","\t\tFacesLocal.addResponseCookie(getContext(), name, value, domain, path, maxAge);","\t}","","\t/**","\t * Add a cookie with given name, value, domain, path, maxage and HttpOnly flag to the HTTP response.","\t * The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored.","\t * The cookie will implicitly be set to secure when the current request is a HTTPS request.","\t * @param name The cookie name.","\t * @param value The cookie value.","\t * @param domain The cookie domain. You can use .example.com
(with a leading period) if you'd like the","\t * cookie to be available to all subdomains of the domain. Note that you cannot set it to a different domain.","\t * Defaults to {@link #getRequestHostname()} when null
.","\t * @param path The cookie path. If this is /
, then the cookie is available in all pages of the webapp.","\t * If this is /somespecificpath
, then the cookie is only available in pages under the specified path.","\t * @param maxAge The maximum age of the cookie, in seconds. If this is 0
, then the cookie will be","\t * removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is","\t * -1
then the cookie will become a session cookie and thus live as long as the established HTTP","\t * session.","\t * @param httpOnly When set to true, then JavaScript is not allowed to manipulate the cookie.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UnsupportedOperationException When this platform does not support UTF-8.","\t * @see ExternalContext#addResponseCookie(String, String, Map)","\t * @since 3.3","\t */","\tpublic static void addResponseCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly) {","\t\tFacesLocal.addResponseCookie(getContext(), name, value, domain, path, maxAge, httpOnly);","\t}","","\t/**","\t * Add a cookie with given name, value, domain, path, maxage, HttpOnly flag and custom attributes to the HTTP response.","\t * The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored.","\t * The cookie will implicitly be set to secure when the current request is a HTTPS request.","\t * @param name The cookie name.","\t * @param value The cookie value.","\t * @param domain The cookie domain. You can use .example.com
(with a leading period) if you'd like the","\t * cookie to be available to all subdomains of the domain. Note that you cannot set it to a different domain.","\t * Defaults to {@link #getRequestHostname()} when null
.","\t * @param path The cookie path. If this is /
, then the cookie is available in all pages of the webapp.","\t * If this is /somespecificpath
, then the cookie is only available in pages under the specified path.","\t * @param maxAge The maximum age of the cookie, in seconds. If this is 0
, then the cookie will be","\t * removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is","\t * -1
then the cookie will become a session cookie and thus live as long as the established HTTP","\t * session.","\t * @param httpOnly When set to true, then JavaScript is not allowed to manipulate the cookie.","\t * @param attributes Any custom attributes you'd like to add to the cookie, such as SameSite:None
. Any","\t * key whose name matches a predefined cookie attribute name, such as domain
, path
,","\t * HttpOnly
, etc, will override them. If the underlying Faces and/or Servlet implementation does not","\t * allow a certain custom attribute, then it will throw {@link IllegalArgumentException}.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws UnsupportedOperationException When this platform does not support UTF-8.","\t * @throws IllegalArgumentException When a custom attribute is specified which is not supported by the underlying","\t * Faces and/or Servlet implementation. As of now, it's only supported when running minimally Faces 4 on on top of","\t * minimally Servlet 6.","\t * @see ExternalContext#addResponseCookie(String, String, Map)","\t * @since 4.0","\t */","\tpublic static void addResponseCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly, Mapcreate
argument is","\t * true
, otherwise don't create one and return null
.","\t * true
if the HTTP session has already been created, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getSession(boolean)","\t * @since 1.1","\t */","\tpublic static boolean hasSession() {","\t\treturn FacesLocal.hasSession(getContext());","\t}","","\t/**","\t * Returns whether the HTTP session has been created for the first time in the current request. This returns also","\t * false
when there is no means of a HTTP session.","\t * @return true
if the HTTP session has been created for the first time in the current request,","\t * otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getSession(boolean)","\t * @see HttpSession#isNew()","\t * @since 1.1","\t */","\tpublic static boolean isSessionNew() {","\t\treturn FacesLocal.isSessionNew(getContext());","\t}","","\t/**","\t * Returns whether the requested HTTP session is expired.","\t * #{faces.requestedSessionExpired}
.","\t * @return true
if the requested HTTP session is expired, otherwise false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestedSessionId()","\t * @see HttpServletRequest#isRequestedSessionIdValid()","\t * @since 3.13","\t */","\tpublic static boolean isRequestedSessionExpired() {","\t\treturn FacesLocal.isRequestedSessionExpired(getContext());","\t}","","\t/**","\t * Returns the time when the HTTP session was created, measured in epoch time. This implicitly creates the session","\t * if one doesn't exist.","\t * @return The time when the HTTP session was created.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpSession#getCreationTime()","\t * @since 1.1","\t */","\tpublic static long getSessionCreationTime() {","\t\treturn FacesLocal.getSessionCreationTime(getContext());","\t}","","\t/**","\t * Returns the time of the previous request associated with the current HTTP session, measured in epoch time. This","\t * implicitly creates the session if one doesn't exist.","\t * @return The time of the previous request associated with the current HTTP session.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpSession#getLastAccessedTime()","\t * @since 1.1","\t */","\tpublic static long getSessionLastAccessedTime() {","\t\treturn FacesLocal.getSessionLastAccessedTime(getContext());","\t}","","\t/**","\t * Returns the HTTP session timeout in seconds. This implicitly creates the session if one doesn't exist.","\t * @return The HTTP session timeout in seconds.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getSessionMaxInactiveInterval()","\t * @since 1.1","\t */","\tpublic static int getSessionMaxInactiveInterval() {","\t\treturn FacesLocal.getSessionMaxInactiveInterval(getContext());","\t}","","\t/**","\t * Sets the HTTP session timeout in seconds. A value of 0 or less means that the session should never timeout.","\t * This implicitly creates the session if one doesn't exist.","\t * @param seconds The HTTP session timeout in seconds.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#setSessionMaxInactiveInterval(int)","\t * @since 1.1","\t */","\tpublic static void setSessionMaxInactiveInterval(int seconds) {","\t\tFacesLocal.setSessionMaxInactiveInterval(getContext(), seconds);","\t}","","\t/**","\t * Returns whether the HTTP session has been timed out for the current request. This is helpful if you need to","\t * distinguish between a first-time request on a fresh session and a first-time request on a timed out session, for","\t * example to display \"Oops, you have been logged out because your session has been timed out!\".","\t * @return true
if the HTTP session has been timed out for the current request, otherwise","\t * false
.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see HttpServletRequest#getRequestedSessionId()","\t * @see HttpServletRequest#isRequestedSessionIdValid()","\t * @since 1.1","\t */","\tpublic static boolean hasSessionTimedOut() {","\t\treturn FacesLocal.hasSessionTimedOut(getContext());","\t}","","\t// Servlet context ------------------------------------------------------------------------------------------------","","\t/**","\t * Returns the servlet context.","\t * <context-param>
entries in in web.xml
.","\t * @return The application initialization parameter map.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getInitParameterMap()","\t * @since 1.1","\t */","\tpublic static Map<param-value>
of a","\t * <context-param>
in web.xml
associated with the given","\t * <param-name>
.","\t * @param name The application initialization parameter name.","\t * @return The application initialization parameter value associated with the given name, or null
if","\t * there is none.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getInitParameter(String)","\t * @since 1.1","\t */","\tpublic static String getInitParameter(String name) {","\t\treturn FacesLocal.getInitParameter(getContext(), name);","\t}","","\t/**","\t * Returns the application initialization parameter. This returns the <param-value>
of a","\t * <context-param>
in web.xml
associated with the given","\t * <param-name>
.","\t * @param name The application initialization parameter name.","\t * @param defaultValue The default value if there is no application initialization parameter value associated with the given name.","\t * @return The application initialization parameter value associated with the given name, or defaultValue
if","\t * there is none.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getInitParameter(String)","\t * @since 3.1","\t */","\tpublic static String getInitParameterOrDefault(String name, String defaultValue) {","\t\treturn FacesLocal.getInitParameterOrDefault(getContext(), name, defaultValue);","\t}","","\t/**","\t * Returns the mime type for the given file name. The mime type is determined based on file extension and","\t * configureable by <mime-mapping>
entries in web.xml
. When the mime type is","\t * unknown, then a default of application/octet-stream
will be returned.","\t * @param name The file name to return the mime type for.","\t * @return The mime type for the given file name.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getMimeType(String)","\t */","\tpublic static String getMimeType(String name) {","\t\treturn FacesLocal.getMimeType(getContext(), name);","\t}","","\t/**","\t * Returns a URL for an application resource mapped to the specified path, if it exists; otherwise, return","\t * null
.","\t * @param path The application resource path to return an input stream for.","\t * @return An input stream for an application resource mapped to the specified path.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws MalformedURLException When the specified path is not in correct URL form.","\t * @see ExternalContext#getResource(String)","\t * @since 1.2","\t */","\tpublic static URL getResource(String path) throws MalformedURLException {","\t\treturn FacesLocal.getResource(getContext(), path);","\t}","","\t/**","\t * Returns an input stream for an application resource mapped to the specified path, if it exists; otherwise,","\t * return null
.","\t * @param path The application resource path to return an input stream for.","\t * @return An input stream for an application resource mapped to the specified path.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getResourceAsStream(String)","\t */","\tpublic static InputStream getResourceAsStream(String path) {","\t\treturn FacesLocal.getResourceAsStream(getContext(), path);","\t}","","\t/**","\t * Returns a set of available application resource paths matching the specified path.","\t * @param path The partial application resource path used to return matching resource paths.","\t * @return A set of available application resource paths matching the specified path.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getResourcePaths(String)","\t */","\tpublic static Set/index.xhtml
) to an absolute disk file system path (e.g.","\t * /path/to/server/work/folder/some.war/index.xhtml
) which can then be used in {@link File},","\t * {@link FileInputStream}, etc.","\t * null
when the WAR is not expanded into the disk file system, but instead","\t * into memory. If all you want is just an {@link InputStream} of the web content resource, then better use","\t * {@link #getResourceAsStream(String)} instead.","\t * T
is of wrong type.","\t * @see ExternalContext#getRequestMap()","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getRequestMap()","\t * @since 3.0","\t */","\tpublic static null
if","\t * there is no such attribute.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getRequestMap()","\t * @since 1.1","\t */","\tpublic static Flash
implements Map<String, Object>
, so you","\t * can just treat it like a Map<String, Object>
.","\t * @return The flash scope.","\t * @throws NullPointerException When faces context is unavailable.","\t * @see ExternalContext#getFlash()","\t */","\tpublic static Flash getFlash() {","\t\treturn FacesLocal.getFlash(getContext());","\t}","","\t/**","\t * Returns the flash scope attribute value associated with the given name.","\t * @param T
is of wrong type.","\t * @see ExternalContext#getFlash()","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getFlash()","\t * @since 3.0","\t */","\tpublic static null
if","\t * there is no such attribute.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getFlash()","\t * @since 1.1","\t */","\tpublic static T
is of wrong type.","\t * @see UIViewRoot#getViewMap()","\t */","\tpublic static T
is of wrong type.","\t * @see UIViewRoot#getViewMap()","\t * @since 3.0","\t */","\tpublic static null
if","\t * there is no such attribute.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see UIViewRoot#getViewMap()","\t * @since 1.1","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getSessionMap()","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getSessionMap()","\t * @since 3.0","\t */","\tpublic static null
if","\t * there is no such attribute.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getSessionMap()","\t * @since 1.1","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getApplicationMap()","\t */","\tpublic static T
is of wrong type.","\t * @see ExternalContext#getApplicationMap()","\t * @since 3.0","\t */","\tpublic static null
if","\t * there is no such attribute.","\t * @throws NullPointerException When faces context is unavailable.","\t * @throws ClassCastException When T
is of wrong type.","\t * @see ExternalContext#getApplicationMap()","\t * @since 1.1","\t */","\tpublic static