- java.lang.Object
- 
- org.omnifaces.util.Faces
 
- 
 public final class Faces extends Object Collection of utility methods for the Faces API that are mainly shortcuts for obtaining stuff from the thread local 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 getLocale()which returns sane fallback values, a more convenientredirect(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 usefulsendFile(File, boolean)methods which allows you to provide aFile,byte[]orInputStreamas a download to the client.UsageHere 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. FacesLocalNote that there's normally a minor overhead in obtaining the thread local 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 theFacesContextis 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 FacesLocalinstead. The difference withFacesis that no one method ofFacesLocalobtains theFacesContextfrom the current thread byFacesContext.getCurrentInstance(). This job is up to the caller.#{faces} in ELSince OmniFaces 2.6, all methods of Facesutility class which start with "get" or "is", and take no parameters, and return eitherStringorboolean, 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, Bauke Scholtz
- See Also:
- FacesLocal,- Servlets,- FacesELResolver
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddResponseCookie(String name, String value, int maxAge)Add a cookie with given name, value and maxage to the HTTP response.static voidaddResponseCookie(String name, String value, String path, int maxAge)Add a cookie with given name, value, path and maxage to the HTTP response.static voidaddResponseCookie(String name, String value, String domain, String path, int maxAge)Add a cookie with given name, value, domain, path and maxage to the HTTP response.static voidaddResponseCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly)Add a cookie with given name, value, domain, path, maxage and HttpOnly flag to the HTTP response.static voidaddResponseCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly, Map<String,String> attributes)Add a cookie with given name, value, domain, path, maxage, HttpOnly flag and custom attributes to the HTTP response.static voidaddResponseHeader(String name, String value)Add a header with given name and value to the HTTP response.static booleanauthenticate()Trigger the default container managed authentication mechanism on the current request.static <T> Converter<T>createConverter(Class<?> identifier)Creates and returns a Faces converter associated with given class identifier.static <T> Converter<T>createConverter(Object identifier)Creates and returns a Faces converter associated with given object identifier.static <T> Converter<T>createConverter(String identifier)Creates and returns a Faces converter associated with given string identifier.static ResourcecreateResource(String resourceName)Creates and returns a Faces resource associated with given resource name.static ResourcecreateResource(String libraryName, String resourceName)Creates and returns a Faces resource associated with given library name and resource name.static ResourcecreateResource(ResourceIdentifier resourceIdentifier)Creates and returns a Faces resource associated with given resource identifier.static <T> Validator<T>createValidator(Class<?> identifier)Creates and returns a Faces validator associated with given class identifier.static <T> Validator<T>createValidator(Object identifier)Creates and returns a Faces validator associated with given object identifier.static <T> Validator<T>createValidator(String identifier)Creates and returns a Faces validator associated with given string identifier.static <T> TevaluateExpressionGet(String expression)Programmatically evaluate the given EL expression and return the evaluated value.static voidevaluateExpressionSet(String expression, Object value)Programmatically evaluate the given EL expression and set the given value.static ApplicationgetApplication()Returns the application singleton.static <T> TgetApplicationAttribute(String name)Returns the application scope attribute value associated with the given name.static <T> TgetApplicationAttribute(String name, Supplier<T> computeIfAbsent)Returns the application scope attribute value associated with the given name, or computes the supplied value if absent.static ApplicationgetApplicationFromFactory()Gets the Faces Application singleton from the FactoryFinder.static Map<String,Object>getApplicationMap()Returns the application scope map.static StringgetBookmarkableURL(String viewId, Collection<? extends ParamHolder<?>> params, boolean includeViewParams)Returns the concrete domain-relative URL to the given view with the given params URL-encoded in the query string and optionally include view parameters as well.static StringgetBookmarkableURL(String viewId, Map<String,List<String>> params, boolean includeViewParams)Returns the concrete domain-relative URL to the given view with the given params URL-encoded in the query string and optionally include view parameters as well.static StringgetBookmarkableURL(Collection<? extends ParamHolder<?>> params, boolean includeViewParams)Returns the concrete domain-relative URL to the current view with the given params URL-encoded in the query string and optionally include view parameters as well.static StringgetBookmarkableURL(Map<String,List<String>> params, boolean includeViewParams)Returns the concrete domain-relative URL to the current view with the given params URL-encoded in the query string and optionally include view parameters as well.static StringgetBundleString(String key)Gets a string for the given key searching declared resource bundles, order by declaration infaces-config.xml.static FacesContextgetContext()Returns the current faces context.static FacesContextgetContext(ELContext elContext)Returns the faces context that's stored in an ELContext.static <T> TgetContextAttribute(String name)Returns the Faces context attribute value associated with the given name.static <T> TgetContextAttribute(String name, Supplier<T> computeIfAbsent)Returns the Faces context attribute value associated with the given name, or computes the supplied value if absent.static PhaseIdgetCurrentPhaseId()Returns the current phase ID.static LocalegetDefaultLocale()Returns the default locale, ornullif there is none.static ELContextgetELContext()Returns the current EL context.static ExternalContextgetExternalContext()Returns the current external context.static <T> TgetFaceletAttribute(String name)Returns the Facelet attribute value associated with the given name.static FaceletContextgetFaceletContext()Returns the Facelet context.static FlashgetFlash()Returns the flash scope.static <T> TgetFlashAttribute(String name)Returns the flash scope attribute value associated with the given name.static <T> TgetFlashAttribute(String name, Supplier<T> computeIfAbsent)Returns the flash scope attribute value associated with the given name, or computes the supplied value if absent.static Map<String,List<String>>getHashParameterMap()Returns the hash parameters of the current view as a parameter map, or an empty map if there is no view.static Collection<HashParam>getHashParameters()Returns the hash parameters of the current view, or an empty collection if there is no view.static StringgetHashQueryString()Returns the hash query string of the current view, ornullif there is none.static StringgetImplInfo()Returns the implementation information of currently loaded Faces implementation.static StringgetInitParameter(String name)Returns the application initialization parameter.static Map<String,String>getInitParameterMap()Returns the application initialization parameter map.static StringgetInitParameterOrDefault(String name, String defaultValue)Returns the application initialization parameter.static LifecyclegetLifecycle()Returns TheLifecycleassociated with current Faces application.static LocalegetLocale()Returns the current locale.static StringgetMapping()Determines and returns the faces servlet mapping used in the current request.static ResourceBundlegetMessageBundle()Returns the application message bundle as identified by<message-bundle>infaces-config.xml.static <T> TgetMetadataAttribute(String name)Returns the metadata attribute of the current view associated with the given name.static <T> TgetMetadataAttribute(String viewId, String name)Returns the metadata attribute of the given view ID associated with the given name.static Map<String,Object>getMetadataAttributes()Returns the metadata attribute map of the current view, or an empty map if there is no view metadata.static Map<String,Object>getMetadataAttributes(String viewId)Returns the metadata attribute map of the given view ID, or an empty map if there is no view metadata.static StringgetMimeType(String name)Returns the mime type for the given file name.static Map<String,List<String>>getMutableRequestHeaderMap()Returns the mutable request header map.static Map<String,List<String>>getMutableRequestParameterMap()Returns the mutable request parameter map.static PackagegetPackage()Returns the package of the currently loaded Faces implementation.static ProjectStagegetProjectStage()Returns the project stage.static StringgetRealPath(String webContentPath)Returns the absolute disk file system path representation of the given web content path.static StringgetReferrer()Returns the referrer of the request.static StringgetRemoteAddr()Returns the Internet Protocol (IP) address of the client that sent the request.static StringgetRemoteUser()Returns the name of the logged-in user for container managed FORM based authentication, if any.static RenderKitgetRenderKit()Returns theRenderKitassociated with the "current" view ID or view handler.static HttpServletRequestgetRequest()Returns the HTTP servlet request.static <T> TgetRequestAttribute(String name)Returns the request scope attribute value associated with the given name.static <T> TgetRequestAttribute(String name, Supplier<T> computeIfAbsent)Returns the request scope attribute value associated with the given name, or computes the supplied value if absent.static StringgetRequestBaseURL()Returns the HTTP request base URL.static StringgetRequestContextPath()Returns the HTTP request context path.static StringgetRequestCookie(String name)Returns the value of the HTTP request cookie associated with the given name.static StringgetRequestDomainURL()Returns the HTTP request domain URL.static StringgetRequestHeader(String name)Returns the HTTP request header value associated with the given name.static Map<String,String>getRequestHeaderMap()Returns the HTTP request header map.static String[]getRequestHeaderValues(String name)Returns the HTTP request header values associated with the given name.static Map<String,String[]>getRequestHeaderValuesMap()Returns the HTTP request header values map.static StringgetRequestHostname()Returns the HTTP request hostname.static Map<String,Object>getRequestMap()Returns the request scope map.static StringgetRequestParameter(String name)Returns the HTTP request parameter value associated with the given name.static <T> TgetRequestParameter(String name, Class<T> type)Returns the HTTP request parameter value associated with the given name and implicitly converted to given type using the Faces converter registered byforClasson the given type.static <T> TgetRequestParameter(String name, Function<String,T> converter)Returns the HTTP request parameter value associated with the given name and converted using the given converter.static <T> TgetRequestParameter(String name, Function<String,T> converter, Supplier<T> defaultValue)Returns the HTTP request parameter value associated with the given name and convert it using the given converter, or else the supplied value if absent.static Map<String,String>getRequestParameterMap()Returns the HTTP request parameter map.static String[]getRequestParameterValues(String name)Returns the HTTP request parameter values associated with the given name.static <T> T[]getRequestParameterValues(String name, Class<T> type)Returns the HTTP request parameter values associated with the given name and implicitly convert it to given type using the Faces converter registered byforClasson the given type.static Map<String,String[]>getRequestParameterValuesMap()Returns the HTTP request parameter values map.static PartgetRequestPart(String name)Returns the HTTP request part associated with the given name, else return null.static Collection<Part>getRequestParts()Returns all HTTP request parts, provided that request is of typemultipart/form-data.static Collection<Part>getRequestParts(String name)Returns all HTTP request parts associated with the given name, provided that request is of typemultipart/form-data.static StringgetRequestPathInfo()Returns the HTTP request path info, taking into account whether FacesViews is used with MultiViews enabled.static StringgetRequestQueryString()Returns the HTTP request query string.static Map<String,List<String>>getRequestQueryStringMap()Returns the HTTP request query string as parameter values map.static StringgetRequestServletPath()Returns the HTTP request servlet path.static StringgetRequestURI()Returns the HTTP request URI.static StringgetRequestURIWithQueryString()Returns the HTTP request URI with query string.static StringgetRequestURL()Returns the HTTP request URL.static StringgetRequestURLWithQueryString()Returns the HTTP request URL with query string.static URLgetResource(String path)Returns a URL for an application resource mapped to the specified path, if it exists; otherwise, returnnull.static InputStreamgetResourceAsStream(String path)Returns an input stream for an application resource mapped to the specified path, if it exists; otherwise, returnnull.static ResourceBundlegetResourceBundle(String var)Returns the application resource bundle as identified by the given<var>of the<resource-bundle>infaces-config.xml.static Map<String,ResourceBundle>getResourceBundles()Returns all application resource bundles registered as<resource-bundle>infaces-config.xml.static Set<String>getResourcePaths(String path)Returns a set of available application resource paths matching the specified path.static HttpServletResponsegetResponse()Returns the HTTP servlet response.static intgetResponseBufferSize()Returns the HTTP response buffer size.static StringgetResponseCharacterEncoding()Returns the HTTP response character encoding.static Collection<ScriptParam>getScriptParameters()Returns the script parameters of the current view, or an empty collection if there is no view.static StringgetServerInfo()Returns the server information of currently running application server implementation.static ServletContextgetServletContext()Returns the servlet context.static HttpSessiongetSession()Returns the HTTP session and creates one if one doesn't exist.static HttpSessiongetSession(boolean create)Returns the HTTP session and creates one if one doesn't exist andcreateargument istrue, otherwise don't create one and returnnull.static <T> TgetSessionAttribute(String name)Returns the session scope attribute value associated with the given name.static <T> TgetSessionAttribute(String name, Supplier<T> computeIfAbsent)Returns the session scope attribute value associated with the given name, or computes the supplied value if absent.static longgetSessionCreationTime()Returns the time when the HTTP session was created, measured in epoch time.static StringgetSessionId()Returns a string containing the unique identifier assigned to this session.static longgetSessionLastAccessedTime()Returns the time of the previous request associated with the current HTTP session, measured in epoch time.static Map<String,Object>getSessionMap()Returns the session scope map.static intgetSessionMaxInactiveInterval()Returns the HTTP session timeout in seconds.static List<Locale>getSupportedLocales()Returns an unordered list of all supported locales on this application, with the default locale as the first item, if any.static StringgetUserAgent()Returns the User-Agent string of the client.static <T> TgetViewAttribute(String name)Returns the view scope attribute value associated with the given name.static <T> TgetViewAttribute(String name, Supplier<T> computeIfAbsent)Returns the view scope attribute value associated with the given name, or computes the supplied value if absent.static ViewDeclarationLanguagegetViewDeclarationLanguage()Returns theViewDeclarationLanguageassociated with the "current" view ID.static StringgetViewId()Returns the ID of the current view root, ornullif there is no view.static StringgetViewIdWithParameters()Returns the ID of the current view root with view and hash parameters.static Map<String,Object>getViewMap()Returns the view scope map.static StringgetViewName()Returns the base name of the current view, without extension, ornullif there is no view.static Map<String,List<String>>getViewParameterMap()Returns the view parameters of the current view as a parameter map, or an empty map if there is no view.static Collection<UIViewParameter>getViewParameters()Returns the view parameters of the current view, or an empty collection if there is no view.static UIViewRootgetViewRoot()Returns the current view root.static booleanhasContext()Returnstruewhen the current faces context is available (i.e. it is notnull).static booleanhasSession()Returns whether the HTTP session has already been created.static booleanhasSessionTimedOut()Deprecated, for removal: This API element is subject to removal in a future version.UseisRequestedSessionExpired()instead.static voidinvalidateSession()Invalidates the current HTTP session.static booleanisAjaxRequest()Returns whether the current request is an ajax request.static booleanisAjaxRequestWithPartialRendering()Returns whether the current request is an ajax request with partial rendering.static booleanisAuthenticated()Returns whether the current request is authenticated, i.e. it has a logged-in user.static booleanisDevelopment()Returns whether we're in development stage.static booleanisPostback()Returns whether the current request is a postback.static booleanisPrefixMapping()Returns whether the faces servlet mapping used in the current request is a prefix mapping.static booleanisPrefixMapping(String mapping)Returns whether the given faces servlet mapping is a prefix mapping.static booleanisProduction()Returns whether we're in production stage.static booleanisRenderResponse()Returnstrueif we're currently in the render response phase.static booleanisRequestedSessionExpired()Returns whether the requested HTTP session is expired.static booleanisRequestSecure()Returnstrueif connection is secure,falseotherwise.static booleanisResponseCommitted()Returns whether the response is already committed.static booleanisResponseComplete()Returnstrueif theFacesContext.responseComplete()has been called.static booleanisSessionNew()Returns whether the HTTP session has been created for the first time in the current request.static booleanisSystemTest()Returns whether we're in system test stage.static booleanisUserInRole(String role)Returns whether the currently logged-in user has the given role.static booleanisValidationFailed()Returns whether the validations phase of the current request has failed.static voidlogin(String username, String password)Perform programmatic login for container managed FORM based authentication.static voidlogout()Perform programmatic logout for container managed FORM based authentication.static voidnavigate(String outcome)Perform the Faces navigation to the given outcome.static StringnormalizeViewId(String path)Normalize the given path as a valid view ID based on the current mapping, if necessary.static voidredirect(String url, Object... paramValues)Sends a temporary (302) redirect to the given URL.static voidredirectPermanent(String url, Object... paramValues)Sends a permanent (301) redirect to the given URL.static voidrefresh()Refresh the current page by a GET request.static voidrefreshWithQueryString()Refresh the current page by a GET request, maintaining the query string.static <T> TremoveApplicationAttribute(String name)Removes the application scope attribute value associated with the given name.static <T> TremoveFlashAttribute(String name)Removes the flash scope attribute value associated with the given name.static <T> TremoveRequestAttribute(String name)Removes the request scope attribute value associated with the given name.static voidremoveResponseCookie(String name, String path)Remove the cookie with given name and path from the HTTP response.static <T> TremoveSessionAttribute(String name)Removes the session scope attribute value associated with the given name.static <T> TremoveViewAttribute(String name)Removes the view scope attribute value associated with the given name.static voidrenderResponse()Signals Faces that, as soon as the current phase of the lifecycle has been completed, control should be passed to the Render Response phase, bypassing any phases that have not been executed yet.static <T> TresolveExpressionGet(Object base, String property)Programmatically EL-resolve the given property on the given base object and return the resolved value.static voidresolveExpressionSet(Object base, String property, Object value)Programmatically EL-resolve the given property on the given base object and set the given value.static voidresponseComplete()Signals Faces that the response for this request has already been generated (such as providing a file download), and that the lifecycle should be terminated as soon as the current phase is completed.static voidresponseReset()Resets the current response.static voidresponseSendError(int status, String message)Sends a HTTP response error with the given status and message.static voidsendFile(byte[] content, String filename, boolean attachment)Send the given byte array as a file to the response.static voidsendFile(File file, boolean attachment)Send the given file to the response.static voidsendFile(File file, String filename, boolean attachment)Send the given file to the response.static voidsendFile(InputStream content, String filename, boolean attachment)Send the given input stream as a file to the response.static voidsendFile(String filename, boolean attachment, FunctionalInterfaces.ThrowingConsumer<OutputStream> outputCallback)Send a file to the response whose content is provided via given output stream callback.static voidsendFile(Path path, boolean attachment)Send the given path as a file to the response.static voidsendFile(Path path, String filename, boolean attachment)Send the given path as a file to the response.static voidsetApplicationAttribute(String name, Object value)Sets the application scope attribute value associated with the given name.static voidsetContext(FacesContext context)Sets the given faces context as current instance.static voidsetContextAttribute(String name, Object value)Sets the Faces context attribute value associated with the given name.static voidsetFaceletAttribute(String name, Object value)Sets the Facelet attribute value associated with the given name.static voidsetFlashAttribute(String name, Object value)Sets the flash scope attribute value associated with the given name.static voidsetLocale(Locale locale)Set the locale of the current view, which is to be used in localizing of the response.static voidsetRequestAttribute(String name, Object value)Sets the request scope attribute value associated with the given name.static voidsetResponseStatus(int status)Sets the HTTP response status code.static voidsetSessionAttribute(String name, Object value)Sets the session scope attribute value associated with the given name.static voidsetSessionMaxInactiveInterval(int seconds)Sets the HTTP session timeout in seconds.static voidsetViewAttribute(String name, Object value)Sets the view scope attribute value associated with the given name.static voidsetViewRoot(String viewId)Sets the current view root to the given view ID.static voidvalidationFailed()Signals Faces that the validations phase of the current request has failed.
 
- 
- 
- 
Method Detail- 
getContextpublic static FacesContext getContext() Returns the current faces context.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The current faces context.
- See Also:
- FacesContext.getCurrentInstance()
 
 - 
getContextpublic static FacesContext getContext(ELContext elContext) Returns the faces context that's stored in an ELContext.Note that this only works for an ELContext that is created in the context of Faces. - Parameters:
- elContext- the EL context to obtain the faces context from.
- Returns:
- the faces context that's stored in the given ELContext.
- Since:
- 1.2
 
 - 
setContextpublic static void setContext(FacesContext context) Sets the given faces context as current instance. Use this if you have a customFacesContextWrapperwhich you'd like to (temporarily) use as the current instance of the faces context.- Parameters:
- context- The faces context to be set as the current instance.
- Since:
- 1.3
 
 - 
hasContextpublic static boolean hasContext() Returnstruewhen the current faces context is available (i.e. it is notnull).- Returns:
- truewhen the current faces context is available.
- Since:
- 2.0
 
 - 
getExternalContextpublic static ExternalContext getExternalContext() Returns the current external context.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The current external context.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.getExternalContext()
 
 - 
getApplicationpublic static Application getApplication() Returns the application singleton.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The faces application singleton.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.getApplication()
 
 - 
getApplicationFromFactorypublic static Application getApplicationFromFactory() Gets the Faces Application singleton from the FactoryFinder.This method is an alternative for getApplication()for those situations where theFacesContextisn't available.- Returns:
- The faces application singleton.
 
 - 
getPackagepublic static Package getPackage() Returns the package of the currently loaded Faces implementation.This is also available in EL as #{faces['package']}.- Returns:
- The package of the currently loaded Faces implementation.
- Since:
- 3.14
 
 - 
getImplInfopublic static String getImplInfo() Returns the implementation information of currently loaded Faces implementation. E.g. "Mojarra 2.1.7-FCS".This is also available in EL as #{faces.implInfo}.- Returns:
- The implementation information of currently loaded Faces implementation.
- See Also:
- Package.getImplementationTitle(),- Package.getImplementationVersion()
 
 - 
getServerInfopublic static String getServerInfo() Returns the server information of currently running application server implementation.This is also available in EL as #{faces.serverInfo}.- Returns:
- The server information of currently running application server implementation.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ServletContext.getServerInfo()
 
 - 
getProjectStagepublic static ProjectStage getProjectStage() Returns the project stage. This will return thejakarta.faces.PROJECT_STAGEcontext parameter inweb.xml.- Returns:
- The project stage.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.6
- See Also:
- Application.getProjectStage()
 
 - 
isDevelopmentpublic static boolean isDevelopment() Returns whether we're in development stage. This will be the case when thejakarta.faces.PROJECT_STAGEcontext parameter inweb.xmlis set toDevelopment.This is also available in EL as #{faces.development}.- Returns:
- trueif we're in development stage, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- Application.getProjectStage()
 
 - 
isSystemTestpublic static boolean isSystemTest() Returns whether we're in system test stage. This will be the case when thejakarta.faces.PROJECT_STAGEcontext parameter inweb.xmlis set toSystemTest.This is also available in EL as #{faces.systemTest}.- Returns:
- trueif we're in system test stage, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.6
- See Also:
- Application.getProjectStage()
 
 - 
isProductionpublic static boolean isProduction() Returns whether we're in production stage. This will be the case when thejakarta.faces.PROJECT_STAGEcontext parameter inweb.xmlis set toProduction.This is also available in EL as #{faces.production}.- Returns:
- trueif we're in production stage, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.6
- See Also:
- Application.getProjectStage()
 
 - 
getMappingpublic static String getMapping() Determines and returns the faces servlet mapping used in the current request. If Faces is prefix mapped (e.g./faces/*), then this returns the whole path, with a leading slash (e.g./faces). If Faces is suffix mapped (e.g.*.xhtml), then this returns the whole extension (e.g..xhtml).This is also available in EL as #{faces.mapping}.- Returns:
- The faces servlet mapping (without the wildcard).
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When mapping could not be determined.
- See Also:
- getRequestPathInfo(),- getRequestServletPath()
 
 - 
isPrefixMappingpublic static boolean isPrefixMapping() Returns whether the faces servlet mapping used in the current request is a prefix mapping.This is also available in EL as #{faces.prefixMapping}.- Returns:
- trueif the faces servlet mapping used in the current request is a prefix mapping, otherwise- false.
- See Also:
- getMapping(),- isPrefixMapping(String)
 
 - 
isPrefixMappingpublic static boolean isPrefixMapping(String mapping) Returns whether the given faces servlet mapping is a prefix mapping. Use this method in preference toisPrefixMapping()when you already have obtained the mapping fromgetMapping()so that the mapping won't be calculated twice.- Parameters:
- mapping- The mapping to be tested.
- Returns:
- trueif the faces servlet mapping used in the current request is a prefix mapping, otherwise- false.
- Throws:
- NullPointerException- When mapping is- null.
 
 - 
getCurrentPhaseIdpublic static PhaseId getCurrentPhaseId() Returns the current phase ID.- Returns:
- The current phase ID.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.getCurrentPhaseId()
 
 - 
validationFailedpublic static void validationFailed() Signals Faces that the validations phase of the current request has failed. This can be invoked in any other phase than the validations phase. The value can be read byisValidationFailed()in Java and by#{facesContext.validationFailed}in EL.- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.validationFailed()
 
 - 
isValidationFailedpublic static boolean isValidationFailed() Returns whether the validations phase of the current request has failed.This is also available in EL as #{faces.validationFailed}.- Returns:
- trueif the validations phase of the current request has failed, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.isValidationFailed()
 
 - 
getELContextpublic static ELContext getELContext() Returns the current EL context.- Returns:
- The current EL context.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.0
- See Also:
- FacesContext.getELContext()
 
 - 
evaluateExpressionGetpublic static <T> T evaluateExpressionGet(String expression) Programmatically evaluate the given EL expression and return the evaluated value.- Type Parameters:
- T- The expected return type.
- Parameters:
- expression- The EL expression to be evaluated.
- Returns:
- The evaluated value of the given EL expression.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- See Also:
- Application.evaluateExpressionGet(FacesContext, String, Class)
 
 - 
evaluateExpressionSetpublic static void evaluateExpressionSet(String expression, Object value) Programmatically evaluate the given EL expression and set the given value.- Parameters:
- expression- The EL expression to be evaluated.
- value- The value to be set in the property behind the given EL expression.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- Application.getExpressionFactory(),- ExpressionFactory.createValueExpression(ELContext, String, Class),- ValueExpression.setValue(ELContext, Object)
 
 - 
resolveExpressionGetpublic static <T> T resolveExpressionGet(Object base, String property) Programmatically EL-resolve the given property on the given base object and return the resolved value.- Type Parameters:
- T- The expected return type.
- Parameters:
- base- The base object whose property value is to be returned, or null to resolve a top-level variable.
- property- The property or variable to be resolved on the given base.
- Returns:
- The resolved value of the given property on the given base object.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 2.1
- See Also:
- Application.getELResolver(),- ELResolver.getValue(ELContext, Object, Object)
 
 - 
resolveExpressionSetpublic static void resolveExpressionSet(Object base, String property, Object value) Programmatically EL-resolve the given property on the given base object and set the given value.- Parameters:
- base- The base object whose property value is to be set, or null to set a top-level variable.
- property- The property or variable to be set on the given base.
- value- The value to be set in the property on the given base.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.1
- See Also:
- Application.getELResolver(),- ELResolver.setValue(ELContext, Object, Object, Object)
 
 - 
getContextAttributepublic static <T> T getContextAttribute(String name) Returns the Faces context attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The Faces context attribute name.
- Returns:
- The Faces context attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.3
- See Also:
- FacesContext.getAttributes()
 
 - 
getContextAttributepublic static <T> T getContextAttribute(String name, Supplier<T> computeIfAbsent) Returns the Faces context attribute value associated with the given name, or computes the supplied value if absent.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The Faces context attribute name.
- computeIfAbsent- The computed Faces context attribute value when absent. Useful if it represents a collection, map or bean.
- Returns:
- The Faces context attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.1
- See Also:
- ExternalContext.getRequestMap()
 
 - 
setContextAttributepublic static void setContextAttribute(String name, Object value) Sets the Faces context attribute value associated with the given name.- Parameters:
- name- The Faces context attribute name.
- value- The Faces context attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.3
- See Also:
- FacesContext.getAttributes()
 
 - 
createConverterpublic static <T> Converter<T> createConverter(Object identifier) Creates and returns a Faces converter associated with given object identifier. If the given identifier is an instance of string, then delegate tocreateConverter(String). If the given identifier is an instance of class, then delegate tocreateConverter(Class). If the given identifier is a concrete converter instance, then return it directly. If no converter instance can be associated, then return null.- Type Parameters:
- T- The expected converter type.
- Parameters:
- identifier- The Faces converter object identifier. This can be a string representing the converter ID, or a class representing the target type, or a class representing the converter class, or even the converter instance itself.
- Returns:
- A Faces converter associated with given object identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
 
 - 
createConverterpublic static <T> Converter<T> createConverter(String identifier) Creates and returns a Faces converter associated with given string identifier. First use the identifier as converter ID inApplication.createConverter(String). If that didn't return anything, then try to interpret the string identifier as class name and delegate tocreateConverter(Class). If no converter instance can be associated, then return null.- Type Parameters:
- T- The expected converter type.
- Parameters:
- identifier- The Faces converter string identifier.
- Returns:
- A Faces converter associated with given string identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
 
 - 
createConverterpublic static <T> Converter<T> createConverter(Class<?> identifier) Creates and returns a Faces converter associated with given class identifier. If the given identifier is not assignable to Converter.class, then use that as target type inApplication.createConverter(Class). If the given identifier is assignable to Converter.class, and theFacesConverterannotation is present, then instantiate it using CDI, else instantiate it using default constructor. If no converter instance can be associated, then return null.- Type Parameters:
- T- The expected converter type.
- Parameters:
- identifier- The Faces converter class identifier.
- Returns:
- A Faces converter associated with given class identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
 
 - 
createValidatorpublic static <T> Validator<T> createValidator(Object identifier) Creates and returns a Faces validator associated with given object identifier. If the given identifier is an instance of string, then delegate tocreateValidator(String). If the given identifier is an instance of class, then delegate tocreateValidator(Class). If the given identifier is a concrete validator instance, then return it directly. If no validator instance can be associated, then return null.- Type Parameters:
- T- The expected validator type.
- Parameters:
- identifier- The Faces validator object identifier. This can be a string representing the validator ID, or a class representing the validator class, or even the validator instance itself.
- Returns:
- A Faces validator associated with given object identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
 
 - 
createValidatorpublic static <T> Validator<T> createValidator(String identifier) Creates and returns a Faces validator associated with given string identifier. First use the identifier as validator ID inApplication.createValidator(String). If that didn't return anything, then try to interpret the string identifier as class name and delegate tocreateValidator(Class). If no validator instance can be associated, then return null.- Type Parameters:
- T- The expected validator type.
- Parameters:
- identifier- The Faces validator string identifier.
- Returns:
- A Faces validator associated with given string identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
 
 - 
createValidatorpublic static <T> Validator<T> createValidator(Class<?> identifier) Creates and returns a Faces validator associated with given class identifier. If the given identifier is assignable to Validator.class, and theFacesValidatorannotation is present, then instantiate it using CDI, else instantiate it using default constructor. If no validator instance can be associated, then return null.- Type Parameters:
- T- The expected validator type.
- Parameters:
- identifier- The Faces validator class identifier.
- Returns:
- A Faces validator associated with given class identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
 
 - 
createResourcepublic static Resource createResource(String resourceName) Creates and returns a Faces resource associated with given resource name. If no resource can be allocated, then return null.- Parameters:
- resourceName- The resource name.
- Returns:
- A Faces resource associated with given resource name.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.6
- See Also:
- ResourceHandler.createResource(String)
 
 - 
createResourcepublic static Resource createResource(String libraryName, String resourceName) Creates and returns a Faces resource associated with given library name and resource name. If no resource can be allocated, then return null.- Parameters:
- libraryName- The library name.
- resourceName- The resource name.
- Returns:
- A Faces resource associated with given library name and resource name.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.6
- See Also:
- ResourceHandler.createResource(String, String)
 
 - 
createResourcepublic static Resource createResource(ResourceIdentifier resourceIdentifier) Creates and returns a Faces resource associated with given resource identifier. If no resource can be allocated, then return null.- Parameters:
- resourceIdentifier- The resource identifier.
- Returns:
- A Faces resource associated with given resource identifier.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.6
- See Also:
- ResourceHandler.createResource(String, String)
 
 - 
getLifecyclepublic static Lifecycle getLifecycle() Returns TheLifecycleassociated with current Faces application.- Returns:
- The Lifecycleassociated with current Faces application.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
- See Also:
- LifecycleFactory.getLifecycle(String)
 
 - 
getViewRootpublic static UIViewRoot getViewRoot() Returns the current view root.- Returns:
- The current view root.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.getViewRoot()
 
 - 
setViewRootpublic static void setViewRoot(String viewId) Sets the current view root to the given view ID. The view ID must start with a leading slash. If an invalid view ID is given, then the response will simply result in a 404.- Parameters:
- viewId- The ID of the view which needs to be set as the current view root.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ViewHandler.createView(FacesContext, String),- FacesContext.setViewRoot(UIViewRoot)
 
 - 
getViewIdpublic static String getViewId() Returns the ID of the current view root, ornullif there is no view.This is also available in EL as #{faces.viewId}, although#{view.viewId}could be used.- Returns:
- The ID of the current view root, or nullif there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- UIViewRoot.getViewId()
 
 - 
getViewIdWithParameterspublic static String getViewIdWithParameters() Returns the ID of the current view root with view and hash parameters.This is also available in EL as #{faces.viewIdWithParameters}.- Returns:
- The ID of the current view root with view and hash parameters.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.5
- See Also:
- UIViewRoot.getViewId(),- ViewMetadata.getViewParameters(UIViewRoot),- getHashParameters()
 
 - 
getViewNamepublic static String getViewName() Returns the base name of the current view, without extension, ornullif there is no view. E.g. if the view ID is/path/to/some.xhtml, then this will returnsome.This is also available in EL as #{faces.viewName}.- Returns:
- The base name of the current view, without extension, or nullif there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.3
- See Also:
- UIViewRoot.getViewId()
 
 - 
getViewDeclarationLanguagepublic static ViewDeclarationLanguage getViewDeclarationLanguage() Returns theViewDeclarationLanguageassociated with the "current" view ID.The current view ID is the view ID that's set for the view root that's associated with the current faces context. - Returns:
- The ViewDeclarationLanguageassociated with the "current" view ID.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.8
 
 - 
getRenderKitpublic static RenderKit getRenderKit() Returns theRenderKitassociated with the "current" view ID or view handler.The current view ID is the view ID that's set for the view root that's associated with the current faces context. Or if there is none, then the current view handler will be assumed, which is the view handler that's associated with the requested view. - Returns:
- The RenderKitassociated with the "current" view ID or view handler.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.2
- See Also:
- UIViewRoot.getRenderKitId(),- ViewHandler.calculateRenderKitId(FacesContext)
 
 - 
normalizeViewIdpublic static String normalizeViewId(String path) Normalize the given path as a valid view ID based on the current mapping, if necessary.- If the current mapping is a prefix mapping and the given path starts with it, then remove it.
- If the current mapping is a suffix mapping and the given path ends with it, then replace it with the default Facelets suffix.
 - Parameters:
- path- The path to be normalized as a valid view ID based on the current mapping.
- Returns:
- The path as a valid view ID.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- getMapping(),- isPrefixMapping(String)
 
 - 
getViewParameterspublic static Collection<UIViewParameter> getViewParameters() Returns the view parameters of the current view, or an empty collection if there is no view.- Returns:
- The view parameters of the current view, or an empty collection if there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ViewMetadata.getViewParameters(UIViewRoot)
 
 - 
getViewParameterMappublic static Map<String,List<String>> getViewParameterMap() Returns the view parameters of the current view as a parameter map, or an empty map if there is no view. This is ready for usage in among othersViewHandler.getBookmarkableURL(FacesContext, String, Map, boolean).- Returns:
- The view parameters of the current view as a parameter map, or an empty map if there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ViewMetadata.getViewParameters(UIViewRoot)
 
 - 
getHashParameterspublic static Collection<HashParam> getHashParameters() Returns the hash parameters of the current view, or an empty collection if there is no view.- Returns:
- The hash parameters of the current view, or an empty collection if there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.2
- See Also:
- HashParam
 
 - 
getHashParameterMappublic static Map<String,List<String>> getHashParameterMap() Returns the hash parameters of the current view as a parameter map, or an empty map if there is no view.- Returns:
- The hash parameters of the current view as a parameter map, or an empty map if there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.2
- See Also:
- HashParam
 
 - 
getHashQueryStringpublic static String getHashQueryString() Returns the hash query string of the current view, ornullif there is none. This is the part after the#in the request URL as the enduser sees in browser address bar. This works only if the hash parameters are via<o:hashParam>registered in the view.- Returns:
- The hash query string of the current view, or nullif there is none.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.2
- See Also:
- HashParam
 
 - 
getScriptParameterspublic static Collection<ScriptParam> getScriptParameters() Returns the script parameters of the current view, or an empty collection if there is no view.- Returns:
- The script parameters of the current view, or an empty collection if there is no view.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.6
- See Also:
- ScriptParam
 
 - 
getMetadataAttributespublic static Map<String,Object> getMetadataAttributes(String viewId) Returns the metadata attribute map of the given view ID, or an empty map if there is no view metadata.- Parameters:
- viewId- The view ID to return the metadata attribute map for.
- Returns:
- The metadata attribute map of the given view ID, or an empty map if there is no view metadata.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.4
- See Also:
- ViewDeclarationLanguage.getViewMetadata(FacesContext, String)
 
 - 
getMetadataAttributespublic static Map<String,Object> getMetadataAttributes() Returns the metadata attribute map of the current view, or an empty map if there is no view metadata.- Returns:
- The metadata attribute map of the current view, or an empty map if there is no view metadata.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.0
- See Also:
- UIComponentBase.getAttributes()
 
 - 
getMetadataAttributepublic static <T> T getMetadataAttribute(String viewId, String name) Returns the metadata attribute of the given view ID associated with the given name. Note: this is not the same as the view scope, for that usegetViewAttribute(String).- Type Parameters:
- T- The expected return type.
- Parameters:
- viewId- The view ID to return the metadata attribute for.
- name- The metadata attribute name.
- Returns:
- The metadata attribute of the given view ID associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.4
- See Also:
- ViewDeclarationLanguage.getViewMetadata(FacesContext, String)
 
 - 
getMetadataAttributepublic static <T> T getMetadataAttribute(String name) Returns the metadata attribute of the current view associated with the given name. Note: this is not the same as the view scope, for that usegetViewAttribute(String).- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The metadata attribute name.
- Returns:
- The metadata attribute of the current view associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.4
- See Also:
- UIComponentBase.getAttributes()
 
 - 
getLocalepublic static Locale getLocale() Returns the current locale. If the locale set in the Faces view root is not null, then return it. Else if the client preferred locale is not null and is among supported locales, then return it. Else if the Faces default locale is not null, then return it. Else return the system default locale.- Returns:
- The current locale.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- UIViewRoot.getLocale(),- ExternalContext.getRequestLocale(),- Application.getDefaultLocale(),- Locale.getDefault()
 
 - 
getDefaultLocalepublic static Locale getDefaultLocale() Returns the default locale, ornullif there is none.- Returns:
- The default locale, or nullif there is none.
- See Also:
- Application.getDefaultLocale()
 
 - 
getSupportedLocalespublic static List<Locale> getSupportedLocales() Returns an unordered list of all supported locales on this application, with the default locale as the first item, if any. This will return an empty list if there are no locales definied infaces-config.xml.- Returns:
- An unordered list of all supported locales on this application, with the default locale as the first
 item, if any. If you need an ordered list, use FacesConfigXml.getSupportedLocales()instead.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- Application.getDefaultLocale(),- Application.getSupportedLocales()
 
 - 
setLocalepublic static void setLocale(Locale locale) Set the locale of the current view, which is to be used in localizing of the response.- Parameters:
- locale- The locale of the current view.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When there is no view (i.e. when it is- null). This can happen if the method is called at the wrong moment in the Faces lifecycle, e.g. before the view has been restored/created.
- Since:
- 1.2
- See Also:
- UIViewRoot.setLocale(Locale)
 
 - 
getMessageBundlepublic static ResourceBundle getMessageBundle() Returns the application message bundle as identified by<message-bundle>infaces-config.xml. The instance is already localized viagetLocale(). If there is no<message-bundle>, then this method just returnsnull.- Returns:
- The message bundle as identified by <message-bundle>infaces-config.xml.
- Throws:
- NullPointerException- When faces context is unavailable.
- MissingResourceException- When the- <message-bundle>in- faces-config.xmldoes not refer an existing resource in the classpath.
- Since:
- 2.0
- See Also:
- Application.getMessageBundle()
 
 - 
getResourceBundlepublic static ResourceBundle getResourceBundle(String var) Returns the application resource bundle as identified by the given<var>of the<resource-bundle>infaces-config.xml. If there is no<resource-bundle>with the given<var>, then this method just returnsnull.- Parameters:
- var- The value of the- <var>which identifies the- <resource-bundle>in- faces-config.xml.
- Returns:
- The application resource bundle as identified by the given <var>of the<resource-bundle>infaces-config.xml.
- Throws:
- NullPointerException- When faces context is unavailable.
- MissingResourceException- When the- <resource-bundle>as identified by the given- <var>in- faces-config.xmldoes not refer an existing resource in the classpath.
- Since:
- 2.0
- See Also:
- Application.getResourceBundle(FacesContext, String)
 
 - 
getResourceBundlespublic static Map<String,ResourceBundle> getResourceBundles() Returns all application resource bundles registered as<resource-bundle>infaces-config.xml. If there are no resource bundles registered, then this method just returns an empty map.- Returns:
- all application resource bundles registered as <resource-bundle>infaces-config.xml.<base-name>of the<resource-bundle>infaces-config.xml.
- Throws:
- NullPointerException- When faces context is unavailable.
- MissingResourceException- When the- <resource-bundle>in- faces-config.xmldoes not refer an existing resource in the classpath.
- Since:
- 2.1
- See Also:
- Application.getResourceBundle(FacesContext, String)
 
 - 
getBundleStringpublic static String getBundleString(String key) Gets a string for the given key searching declared resource bundles, order by declaration infaces-config.xml. If the string is missing, then this method returns???key???.- Parameters:
- key- The bundle key.
- Returns:
- a string for the given key searching declared resource bundles, order by declaration in
 faces-config.xml.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.1
 
 - 
navigatepublic static void navigate(String outcome) Perform the Faces navigation to the given outcome.- Parameters:
- outcome- The navigation outcome.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- Application.getNavigationHandler(),- NavigationHandler.handleNavigation(FacesContext, String, String)
 
 - 
getBookmarkableURLpublic static String getBookmarkableURL(Map<String,List<String>> params, boolean includeViewParams) Returns the concrete domain-relative URL to the current view with the given params URL-encoded in the query string and optionally include view parameters as well. This URL can ultimately be used as redirect URL, or in<form action>, or in<a href>. Any parameter with an empty name or value will be skipped. To skip empty view parameters as well, use<o:viewParam>instead.- Parameters:
- params- The parameters to be URL-encoded in the query string. Can be- null.
- includeViewParams- Whether the view parameters of the current view should be included as well.
- Returns:
- The concrete domain-relative URL to the current view.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When there is no view (i.e. when it is- null). This can happen if the method is called at the wrong moment in the Faces lifecycle, e.g. before the view has been restored/created.
- Since:
- 1.6
- See Also:
- ViewHandler.getBookmarkableURL(FacesContext, String, Map, boolean)
 
 - 
getBookmarkableURLpublic static String getBookmarkableURL(String viewId, Map<String,List<String>> params, boolean includeViewParams) Returns the concrete domain-relative URL to the given view with the given params URL-encoded in the query string and optionally include view parameters as well. This URL can ultimately be used as redirect URL, or in<form action>, or in<a href>. Any parameter with an empty name or value will be skipped. To skip empty view parameters as well, use<o:viewParam>instead.- Parameters:
- viewId- The view ID to create the bookmarkable URL for.
- params- The parameters to be URL-encoded in the query string. Can be- null.
- includeViewParams- Whether the view parameters of the current view which are also declared in the target view should be included as well. Note thus that this does not include the view parameters which are not declared in the target view!
- Returns:
- The concrete domain-relative URL to the target view.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.6
- See Also:
- ViewHandler.getBookmarkableURL(FacesContext, String, Map, boolean)
 
 - 
getBookmarkableURLpublic static String getBookmarkableURL(Collection<? extends ParamHolder<?>> params, boolean includeViewParams) Returns the concrete domain-relative URL to the current view with the given params URL-encoded in the query string and optionally include view parameters as well. This URL can ultimately be used as redirect URL, or in<form action>, or in<a href>. Any parameter with an empty name or value will be skipped. To skip empty view parameters as well, use<o:viewParam>instead.- Parameters:
- params- The parameters to be URL-encoded in the query string. Can be- null.
- includeViewParams- Whether the view parameters of the current view should be included as well.
- Returns:
- The concrete domain-relative URL to the current view.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When there is no view (i.e. when it is- null). This can happen if the method is called at the wrong moment in the Faces lifecycle, e.g. before the view has been restored/created.
- Since:
- 1.7
- See Also:
- ViewHandler.getBookmarkableURL(FacesContext, String, Map, boolean)
 
 - 
getBookmarkableURLpublic static String getBookmarkableURL(String viewId, Collection<? extends ParamHolder<?>> params, boolean includeViewParams) Returns the concrete domain-relative URL to the given view with the given params URL-encoded in the query string and optionally include view parameters as well. This URL can ultimately be used as redirect URL, or in<form action>, or in<a href>. Any parameter with an empty name or value will be skipped. To skip empty view parameters as well, use<o:viewParam>instead.- Parameters:
- viewId- The view ID to create the bookmarkable URL for.
- params- The parameters to be URL-encoded in the query string. Can be- null.
- includeViewParams- Whether the view parameters of the current view which are also declared in the target view should be included as well. Note thus that this does not include the view parameters which are not declared in the target view!
- Returns:
- The concrete domain-relative URL to the target view.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.7
- See Also:
- ViewHandler.getBookmarkableURL(FacesContext, String, Map, boolean)
 
 - 
getFaceletContextpublic static FaceletContext getFaceletContext() Returns the Facelet context.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The Facelet context.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When the Facelet context is not available.
- Since:
- 1.1
- See Also:
- FaceletContext
 
 - 
getFaceletAttributepublic static <T> T getFaceletAttribute(String name) Returns the Facelet attribute value associated with the given name. This basically returns the value of the<ui:param>which is been declared inside the Facelet file, or is been passed into the Facelet file by e.g. an<ui:include>.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The Facelet attribute name.
- Returns:
- The Facelet attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When the Facelet context is not available.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.1
- See Also:
- FaceletContext.getAttribute(String)
 
 - 
setFaceletAttributepublic static void setFaceletAttribute(String name, Object value) Sets the Facelet attribute value associated with the given name. This basically does the same as an<ui:param>which is been declared inside the Facelet file, or is been passed into the Facelet file by e.g. an<ui:include>.- Parameters:
- name- The Facelet attribute name.
- value- The Facelet attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When the Facelet context is not available.
- Since:
- 1.1
- See Also:
- FaceletContext.setAttribute(String, Object)
 
 - 
getRequestpublic static HttpServletRequest getRequest() Returns the HTTP servlet request.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The HTTP servlet request.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequest()
 
 - 
isAjaxRequestpublic static boolean isAjaxRequest() Returns whether the current request is an ajax request.This is also available in EL as #{faces.ajaxRequest}.- Returns:
- truefor an ajax request,- falsefor a non-ajax (synchronous) request.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- PartialViewContext.isAjaxRequest()
 
 - 
isAjaxRequestWithPartialRenderingpublic static boolean isAjaxRequestWithPartialRendering() Returns whether the current request is an ajax request with partial rendering. That is, when it's an ajax request withoutrender="@all".This is also available in EL as #{faces.ajaxRequestWithPartialRendering}.- Returns:
- truefor an ajax request with partial rendering,- falsean ajax request with- render="@all"or a non-ajax (synchronous) request.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 2.3
- See Also:
- PartialViewContext.isAjaxRequest(),- PartialViewContext.isRenderAll()
 
 - 
isPostbackpublic static boolean isPostback() Returns whether the current request is a postback. This not only delegates toFacesContext.isPostback()which checks the presence ofjakarta.faces.ViewStaterequest parameter, but this also explicitly checks the HTTP request method. So this should exclude GET requests having ajakarta.faces.ViewStaterequest parameter in query string.This is also available in EL as #{faces.postback}.- Returns:
- truefor a postback,- falsefor a non-postback (GET) request.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- FacesContext.isPostback()
 
 - 
getRequestParameterMappublic static Map<String,String> getRequestParameterMap() Returns the HTTP request parameter map.- Returns:
- The HTTP request parameter map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestParameterMap()
 
 - 
getMutableRequestParameterMappublic static Map<String,List<String>> getMutableRequestParameterMap() Returns the mutable request parameter map. This requires installation ofMutableRequestFilter.- Returns:
- The mutable request parameter map.
- Throws:
- IllegalStateException- When the- MutableRequestFilteris not installed or not invoked yet.
- Since:
- 3.14
- See Also:
- MutableRequestFilter.getMutableRequest(HttpServletRequest),- MutableRequestFilter.MutableRequest.getMutableParameterMap()
 
 - 
getRequestParameterpublic static String getRequestParameter(String name) Returns the HTTP request parameter value associated with the given name.- Parameters:
- name- The HTTP request parameter name.
- Returns:
- The HTTP request parameter value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestParameterMap()
 
 - 
getRequestParameterpublic static <T> T getRequestParameter(String name, Class<T> type) Returns the HTTP request parameter value associated with the given name and implicitly converted to given type using the Faces converter registered byforClasson the given type. Note that empty strings are already implicitly converted tonull.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The HTTP request parameter name.
- type- The converter- forClasstype.
- Returns:
- The HTTP request parameter value associated with the given name and implicitly converted to given type.
- Throws:
- NullPointerException- When faces context is unavailable.
- ConverterException- When conversion fails.
- ClassCastException- When- Tis of wrong type.
- Since:
- 2.6
- See Also:
- ExternalContext.getRequestParameterMap(),- createConverter(Class)
 
 - 
getRequestParameterpublic static <T> T getRequestParameter(String name, Function<String,T> converter) Returns the HTTP request parameter value associated with the given name and converted using the given converter. Note that empty strings are already implicitly converted tonull.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The HTTP request parameter name.
- converter- The converter.
- Returns:
- The HTTP request parameter value associated with the given name and converted using the given converter.
- Throws:
- NullPointerException- When faces context is unavailable or given converter is- null.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.10
- See Also:
- ExternalContext.getRequestParameterMap()
 
 - 
getRequestParameterpublic static <T> T getRequestParameter(String name, Function<String,T> converter, Supplier<T> defaultValue) Returns the HTTP request parameter value associated with the given name and convert it using the given converter, or else the supplied value if absent. Note that empty strings are already implicitly converted tonull.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The HTTP request parameter name.
- converter- The converter.
- defaultValue- The default request parameter value when absent.
- Returns:
- The HTTP request parameter value associated with the given name and convert it using the given converter, or else the supplied value if absent.
- Throws:
- ClassCastException- When- Tis of wrong type.
- NullPointerException- When faces context is unavailable or given converter or supplier is- null.
- Since:
- 3.10
- See Also:
- ExternalContext.getRequestParameterMap()
 
 - 
getRequestParameterValuesMappublic static Map<String,String[]> getRequestParameterValuesMap() Returns the HTTP request parameter values map.- Returns:
- The HTTP request parameter values map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestParameterValuesMap()
 
 - 
getRequestParameterValuespublic static String[] getRequestParameterValues(String name) Returns the HTTP request parameter values associated with the given name.- Parameters:
- name- The HTTP request parameter name.
- Returns:
- The HTTP request parameter values associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestParameterValuesMap()
 
 - 
getRequestParameterValuespublic static <T> T[] getRequestParameterValues(String name, Class<T> type) Returns the HTTP request parameter values associated with the given name and implicitly convert it to given type using the Faces converter registered byforClasson the given type.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The HTTP request parameter name.
- type- The converter- forClasstype.
- Returns:
- The HTTP request parameter values associated with the given name and implicitly convert it to given type.
- Throws:
- NullPointerException- When faces context is unavailable.
- ConverterException- When conversion fails.
- ClassCastException- When- Tis of wrong type.
- Since:
- 2.6
- See Also:
- ExternalContext.getRequestParameterValuesMap(),- createConverter(Class)
 
 - 
getRequestPartspublic static Collection<Part> getRequestParts() Returns all HTTP request parts, provided that request is of typemultipart/form-data. If there are no parts, an empty collection is returned.- Returns:
- all HTTP request parts.
- Throws:
- NullPointerException- When faces context is unavailable.
- FacesException- Whenever something fails at servlet or I/O level. The caller should preferably not catch it, but just let it go. The servletcontainer will handle it.
- Since:
- 2.5
- See Also:
- HttpServletRequest.getParts()
 
 - 
getRequestPartpublic static Part getRequestPart(String name) Returns the HTTP request part associated with the given name, else return null.- Parameters:
- name- The HTTP request part name.
- Returns:
- The HTTP request part associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- FacesException- Whenever something fails at servlet or I/O level. The caller should preferably not catch it, but just let it go. The servletcontainer will handle it.
- Since:
- 2.5
- See Also:
- HttpServletRequest.getPart(String)
 
 - 
getRequestPartspublic static Collection<Part> getRequestParts(String name) Returns all HTTP request parts associated with the given name, provided that request is of typemultipart/form-data. If there are no parts, an empty collection is returned.- Parameters:
- name- The HTTP request part name.
- Returns:
- All HTTP request parts associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- FacesException- Whenever something fails at servlet or I/O level. The caller should preferably not catch it, but just let it go. The servletcontainer will handle it.
- Since:
- 2.5
- See Also:
- HttpServletRequest.getParts()
 
 - 
getRequestHeaderMappublic static Map<String,String> getRequestHeaderMap() Returns the HTTP request header map.- Returns:
- The HTTP request header map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestHeaderMap()
 
 - 
getMutableRequestHeaderMappublic static Map<String,List<String>> getMutableRequestHeaderMap() Returns the mutable request header map. This requires installation ofMutableRequestFilter.- Returns:
- The mutable request header map.
- Throws:
- IllegalStateException- When the- MutableRequestFilteris not installed or not invoked yet.
- Since:
- 3.14
- See Also:
- MutableRequestFilter.getMutableRequest(HttpServletRequest),- MutableRequestFilter.MutableRequest.getMutableHeaderMap()
 
 - 
getRequestHeaderpublic static String getRequestHeader(String name) Returns the HTTP request header value associated with the given name.- Parameters:
- name- The HTTP request header name.
- Returns:
- The HTTP request header value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestHeaderMap()
 
 - 
getRequestHeaderValuesMappublic static Map<String,String[]> getRequestHeaderValuesMap() Returns the HTTP request header values map.- Returns:
- The HTTP request header values map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestHeaderValuesMap()
 
 - 
getRequestHeaderValuespublic static String[] getRequestHeaderValues(String name) Returns the HTTP request header values associated with the given name.- Parameters:
- name- The HTTP request header name.
- Returns:
- The HTTP request header values associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestHeaderValuesMap()
 
 - 
getRequestContextPathpublic static String getRequestContextPath() Returns the HTTP request context path. It's the webapp context name, with a leading slash. If the webapp runs on context root, then it returns an empty string.This is also available in EL as #{faces.requestContextPath}.- Returns:
- The HTTP request context path.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestContextPath()
 
 - 
getRequestServletPathpublic static String getRequestServletPath() Returns the HTTP request servlet path. If Faces is prefix mapped (e.g./faces/*), then this returns the whole prefix mapping (e.g./faces). If Faces is suffix mapped (e.g.*.xhtml), then this returns the whole part after the context path, with a leading slash.This is also available in EL as #{faces.requestServletPath}.- Returns:
- The HTTP request servlet path.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestServletPath()
 
 - 
getRequestPathInfopublic static String getRequestPathInfo() Returns the HTTP request path info, taking into account whether FacesViews is used with MultiViews enabled. If the resource is prefix mapped (e.g./faces/*), then this returns the whole part after the prefix mapping, with a leading slash. If the resource is suffix mapped (e.g.*.xhtml), then this returnsnull. If MultiViews is enabled, then this returns the part after the mapped view, if any.This is also available in EL as #{faces.requestPathInfo}.- Returns:
- The HTTP request path info.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestPathInfo(),- FacesViews.FACES_VIEWS_ORIGINAL_PATH_INFO
 
 - 
getRequestHostnamepublic static String getRequestHostname() Returns the HTTP request hostname. This is the entire domain, without any scheme and slashes. Noted should be that this value is extracted from the request URL, not fromServletRequest.getServerName()as its outcome can be influenced by proxies.This is also available in EL as #{faces.requestHostName}.- Returns:
- The HTTP request hostname.
- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalArgumentException- When the URL is malformed. This is however unexpected as the request would otherwise not have hit the server at all.
- Since:
- 1.6
- See Also:
- HttpServletRequest.getRequestURL()
 
 - 
getRequestBaseURLpublic static String getRequestBaseURL() Returns the HTTP request base URL. This is the URL from the scheme, domain until with context path, including the trailing slash. This is the value you could use in HTML<base>tag.This is also available in EL as #{faces.requestBaseURL}.- Returns:
- The HTTP request base URL.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- HttpServletRequest.getRequestURL(),- HttpServletRequest.getRequestURI(),- HttpServletRequest.getContextPath()
 
 - 
getRequestDomainURLpublic static String getRequestDomainURL() Returns the HTTP request domain URL. This is the URL with the scheme and domain, without any trailing slash.This is also available in EL as #{faces.requestDomainURL}.- Returns:
- The HTTP request domain URL.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpServletRequest.getRequestURL(),- HttpServletRequest.getRequestURI()
 
 - 
getRequestURLpublic static String getRequestURL() Returns the HTTP request URL. This is the full request URL as the enduser sees in browser address bar. This does not include the request query string.This is also available in EL as #{faces.requestURL}.- Returns:
- The HTTP request URL.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpServletRequest.getRequestURL()
 
 - 
getRequestURIpublic static String getRequestURI() Returns the HTTP request URI. This is the part after the domain in the request URL, including the leading slash. This does not include the request query string.This is also available in EL as #{faces.requestURI}.- Returns:
- The HTTP request URI.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpServletRequest.getRequestURI()
 
 - 
getRequestQueryStringpublic static String getRequestQueryString() Returns the HTTP request query string. This is the part after the?in the request URL as the enduser sees in browser address bar.This is also available in EL as #{faces.requestQueryString}.- Returns:
- The HTTP request query string.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpServletRequest.getQueryString()
 
 - 
getRequestQueryStringMappublic static Map<String,List<String>> getRequestQueryStringMap() Returns the HTTP request query string as parameter values map. Note this method returns only the request URL (GET) parameters, as opposed togetRequestParameterValuesMap(), which contains both the request URL (GET) parameters and the request body (POST) parameters. This is ready for usage in among othersViewHandler.getBookmarkableURL(FacesContext, String, Map, boolean).- Returns:
- The HTTP request query string as parameter values map.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.6
- See Also:
- HttpServletRequest.getQueryString()
 
 - 
getRequestURLWithQueryStringpublic static String getRequestURLWithQueryString() Returns the HTTP request URL with query string. This is the full request URL with query string as the enduser sees in browser address bar.This is also available in EL as #{faces.requestURLWithQueryString}.- Returns:
- The HTTP request URL with query string.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.5
- See Also:
- HttpServletRequest.getRequestURL(),- HttpServletRequest.getQueryString()
 
 - 
getRequestURIWithQueryStringpublic static String getRequestURIWithQueryString() Returns the HTTP request URI with query string. This is the part after the domain in the request URL, including the leading slash and the request query string.This is also available in EL as #{faces.requestURIWithQueryString}.- Returns:
- The HTTP request URI with query string.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.6
- See Also:
- HttpServletRequest.getRequestURI(),- HttpServletRequest.getQueryString()
 
 - 
getRemoteAddrpublic static String getRemoteAddr() Returns the Internet Protocol (IP) address of the client that sent the request. This will first check theX-Forwarded-Forrequest header and if it's present, then return its first IP address, else just returnServletRequest.getRemoteAddr()unmodified.This is also available in EL as #{faces.remoteAddr}.- Returns:
- The IP address of the client.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.2
- See Also:
- ServletRequest.getRemoteAddr()
 
 - 
getUserAgentpublic static String getUserAgent() Returns the User-Agent string of the client.This is also available in EL as #{faces.userAgent}.- Returns:
- The User-Agent string of the client.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.2
- See Also:
- HttpServletRequest.getHeader(String)
 
 - 
getReferrerpublic static String getReferrer() Returns the referrer of the request.This is also available in EL as #{faces.referrer}.- Returns:
- The referrer of the request.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.10
- See Also:
- HttpServletRequest.getHeader(String)
 
 - 
isRequestSecurepublic static boolean isRequestSecure() Returnstrueif connection is secure,falseotherwise. This method will first check ifServletRequest.isSecure()returnstrue, and if nottrue, check if theX-Forwarded-Protois present and equals tohttps.- Returns:
- trueif connection is secure,- falseotherwise.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.0
- See Also:
- ServletRequest.isSecure()
 
 - 
getResponsepublic static HttpServletResponse getResponse() Returns the HTTP servlet response.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The HTTP servlet response.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getResponse()
 
 - 
getResponseBufferSizepublic static int getResponseBufferSize() Returns the HTTP response buffer size. If Facelets is used and thejakarta.faces.FACELETS_BUFFER_SIZEcontext parameter is been set, then it's the context parameter value which will be returned. Otherwise it returns the implementation independent default value, which is 1024 in Mojarra.- Returns:
- The HTTP response buffer size.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.2
- See Also:
- ExternalContext.getResponseBufferSize()
 
 - 
getResponseCharacterEncodingpublic static String getResponseCharacterEncoding() Returns the HTTP response character encoding.- Returns:
- The HTTP response character encoding.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.2
- See Also:
- ExternalContext.getResponseCharacterEncoding()
 
 - 
setResponseStatuspublic static void setResponseStatus(int status) Sets the HTTP response status code. You can use the constant field values ofHttpServletResponsefor this. For example,Faces.setResponseStatus(HttpServletResponse.SC_BAD_REQUEST).- Parameters:
- status- The HTTP status code to be set on the current response.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.6
 
 - 
redirectpublic static void redirect(String url, Object... paramValues) Sends a temporary (302) redirect to the given URL. If the given URL does not start withhttp://,https://or/, then the request context path will be prepended, otherwise it will be the unmodified redirect URL. So, when redirecting to another page in the same web application, always specify the full path from the context root on (which in turn does not need to start with/).Faces.redirect("other.xhtml");You can use String.format(String, Object...)placeholder%sin the redirect URL to represent placeholders for any request parameter values which needs to be URL-encoded. Here's a concrete example:Faces.redirect("other.xhtml?foo=%s&bar=%s", foo, bar);- Parameters:
- url- The URL to redirect the current response to.
- paramValues- The request parameter values which you'd like to put URL-encoded in the given URL.
- Throws:
- NullPointerException- When faces context is unavailable or given url is- null.
- UncheckedIOException- When HTTP response is not available anymore.
- See Also:
- ExternalContext.redirect(String)
 
 - 
redirectPermanentpublic static void redirectPermanent(String url, Object... paramValues) Sends a permanent (301) redirect to the given URL. If the given URL does not start withhttp://,https://or/, then the request context path will be prepended, otherwise it will be the unmodified redirect URL. So, when redirecting to another page in the same web application, always specify the full path from the context root on (which in turn does not need to start with/).Faces.redirectPermanent("other.xhtml");You can use String.format(String, Object...)placeholder%sin the redirect URL to represent placeholders for any request parameter values which needs to be URL-encoded. Here's a concrete example:Faces.redirectPermanent("other.xhtml?foo=%s&bar=%s", foo, bar);This method does by design not work on ajax requests. It is not possible to return a "permanent redirect" via Faces ajax XML response. - Parameters:
- url- The URL to redirect the current response to.
- paramValues- The request parameter values which you'd like to put URL-encoded in the given URL.
- Throws:
- NullPointerException- When faces context is unavailable or given url is- null.
- See Also:
- ExternalContext.setResponseStatus(int),- ExternalContext.setResponseHeader(String, String)
 
 - 
refreshpublic static void refresh() Refresh the current page by a GET request. This basically sends a temporary (302) redirect to current request URI, without query string.- Throws:
- NullPointerException- When faces context is unavailable.
- UncheckedIOException- When HTTP response is not available anymore.
- Since:
- 2.2
- See Also:
- ExternalContext.redirect(String),- HttpServletRequest.getRequestURI()
 
 - 
refreshWithQueryStringpublic static void refreshWithQueryString() Refresh the current page by a GET request, maintaining the query string. This basically sends a temporary (302) redirect to current request URI, with the current query string.- Throws:
- NullPointerException- When faces context is unavailable.
- UncheckedIOException- When HTTP response is not available anymore.
- Since:
- 2.2
- See Also:
- ExternalContext.redirect(String),- HttpServletRequest.getRequestURI(),- HttpServletRequest.getQueryString()
 
 - 
responseSendErrorpublic static void responseSendError(int status, String message)Sends a HTTP response error with the given status and message. This will end up in either a custom<error-page>whose<error-code>matches the given status, or in a servlet container specific default error page if there is none. The message will be available in the error page as a request attribute with namejakarta.servlet.error.message. TheFacesContext.responseComplete()will implicitly be called after sending the error.- Parameters:
- status- The HTTP response status which is supposed to be in the range 4nn-5nn. You can use the constant field values of- HttpServletResponsefor this.
- message- The message which is supposed to be available in the error page.
- Throws:
- NullPointerException- When faces context is unavailable.
- UncheckedIOException- When HTTP response is not available anymore.
- See Also:
- ExternalContext.responseSendError(int, String)
 
 - 
addResponseHeaderpublic static void addResponseHeader(String name, String value) Add a header with given name and value to the HTTP response.- Parameters:
- name- The header name.
- value- The header value.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.addResponseHeader(String, String)
 
 - 
isResponseCommittedpublic static boolean isResponseCommitted() Returns whether the response is already committed. That is, when the response headers and a part of the response body has already been sent to the client. This is usually a point of no return and you can't change the response anymore.- Returns:
- trueif the response is already committed, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.isResponseCommitted()
 
 - 
responseResetpublic static void responseReset() Resets the current response. This will clear any headers which are been set and any data which is written to the response buffer which isn't committed yet.- Throws:
- NullPointerException- When faces context is unavailable.
- IllegalStateException- When the response is already committed.
- Since:
- 1.1
- See Also:
- ExternalContext.responseReset()
 
 - 
renderResponsepublic static void renderResponse() Signals Faces that, as soon as the current phase of the lifecycle has been completed, control should be passed to the Render Response phase, bypassing any phases that have not been executed yet.- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.4
- See Also:
- FacesContext.renderResponse()
 
 - 
isRenderResponsepublic static boolean isRenderResponse() Returnstrueif we're currently in the render response phase. This explicitly checks the current phase ID instead ofFacesContext.getRenderResponse()as the latter may unexpectedly return false during a GET request when<f:viewParam>is been used.This is also available in EL as #{faces.renderResponse}.- Returns:
- trueif we're currently in the render response phase.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.4
- See Also:
- FacesContext.getCurrentPhaseId()
 
 - 
responseCompletepublic static void responseComplete() Signals Faces that the response for this request has already been generated (such as providing a file download), and that the lifecycle should be terminated as soon as the current phase is completed.- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.4
- See Also:
- FacesContext.responseComplete()
 
 - 
isResponseCompletepublic static boolean isResponseComplete() Returnstrueif theFacesContext.responseComplete()has been called.- Returns:
- trueif the- FacesContext.responseComplete()has been called.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.4
- See Also:
- FacesContext.responseComplete()
 
 - 
loginpublic static void login(String username, String password) throws ServletException Perform programmatic login for container managed FORM based authentication. Note that configuration is container specific and unrelated to Faces. Refer the documentation of the servletcontainer using the keyword "realm".- Parameters:
- username- The login username.
- password- The login password.
- Throws:
- NullPointerException- When faces context is unavailable.
- ServletException- When the login is invalid, or when container managed FORM based authentication is not enabled.
- See Also:
- HttpServletRequest.login(String, String)
 
 - 
authenticatepublic static boolean authenticate() throws ServletExceptionTrigger the default container managed authentication mechanism on the current request. It expects the username and password being available as predefinied request parameters on the current request and/or a custom JASPIC implementation.- Returns:
- trueif the authentication was successful, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- ServletException- When the authentication has failed. The caller is responsible for handling it.
- UncheckedIOException- When HTTP request or response is not available anymore.
- Since:
- 1.4
- See Also:
- HttpServletRequest.authenticate(HttpServletResponse)
 
 - 
isAuthenticatedpublic static boolean isAuthenticated() Returns whether the current request is authenticated, i.e. it has a logged-in user.This is also available in EL as #{faces.authenticated}.- Returns:
- trueif the current request is authenticated, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 4.3
- See Also:
- ExternalContext.getRemoteUser()
 
 - 
logoutpublic static void logout() throws ServletExceptionPerform programmatic logout for container managed FORM based authentication. Note that this basically removes the user principal from the session. It's however better practice to just invalidate the session altogether, which will implicitly also remove the user principal. Just invokeinvalidateSession()instead. Note that the user principal is still present in the response of the current request, it's therefore recommend to send a redirect afterlogout()orinvalidateSession(). You can useredirect(String, Object...)for this.- Throws:
- NullPointerException- When faces context is unavailable.
- ServletException- When the logout has failed.
- See Also:
- HttpServletRequest.logout()
 
 - 
getRemoteUserpublic static String getRemoteUser() Returns the name of the logged-in user for container managed FORM based authentication, if any.This is also available in EL as #{faces.remoteUser}.- Returns:
- The name of the logged-in user for container managed FORM based authentication, if any.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRemoteUser()
 
 - 
isUserInRolepublic static boolean isUserInRole(String role) Returns whether the currently logged-in user has the given role.- Parameters:
- role- The role to be checked on the currently logged-in user.
- Returns:
- trueif the currently logged-in user has the given role, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.isUserInRole(String)
 
 - 
getRequestCookiepublic static String getRequestCookie(String name) Returns the value of the HTTP request cookie associated with the given name. The value is implicitly URL-decoded with a charset of UTF-8.- Parameters:
- name- The HTTP request cookie name.
- Returns:
- The value of the HTTP request cookie associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- UnsupportedOperationException- When this platform does not support UTF-8.
- See Also:
- ExternalContext.getRequestCookieMap()
 
 - 
addResponseCookiepublic static void addResponseCookie(String name, String value, int maxAge) Add a cookie with given name, value and maxage to the HTTP response. The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored. The cookie will implicitly be set in the domain and path of the current request URL. The cookie will implicitly be set to HttpOnly as JavaScript is not supposed to manipulate server-created cookies. The cookie will implicitly be set to secure when the current request is a HTTPS request.- Parameters:
- name- The cookie name.
- value- The cookie value.
- maxAge- The maximum age of the cookie, in seconds. If this is- 0, then the cookie will be removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is- -1then the cookie will become a session cookie and thus live as long as the established HTTP session.
- Throws:
- NullPointerException- When faces context is unavailable.
- UnsupportedOperationException- When this platform does not support UTF-8.
- Since:
- 1.8
- See Also:
- ExternalContext.addResponseCookie(String, String, Map)
 
 - 
addResponseCookiepublic static void addResponseCookie(String name, String value, String path, int maxAge) Add a cookie with given name, value, path and maxage to the HTTP response. The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored. The cookie will implicitly be set in the domain of the current request URL. The cookie will implicitly be set to HttpOnly as JavaScript is not supposed to manipulate server-created cookies. The cookie will implicitly be set to secure when the current request is a HTTPS request.- Parameters:
- name- The cookie name.
- value- The cookie value.
- path- The cookie path. If this is- /, then the cookie is available in all pages of the webapp. If this is- /somespecificpath, then the cookie is only available in pages under the specified path.
- maxAge- The maximum age of the cookie, in seconds. If this is- 0, then the cookie will be removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is- -1then the cookie will become a session cookie and thus live as long as the established HTTP session.
- Throws:
- NullPointerException- When faces context is unavailable.
- UnsupportedOperationException- When this platform does not support UTF-8.
- See Also:
- ExternalContext.addResponseCookie(String, String, Map)
 
 - 
addResponseCookiepublic static void addResponseCookie(String name, String value, String domain, String path, int maxAge) Add a cookie with given name, value, domain, path and maxage to the HTTP response. The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored. The cookie will implicitly be set to HttpOnly as JavaScript is not supposed to manipulate server-created cookies. The cookie will implicitly be set to secure when the current request is a HTTPS request.- Parameters:
- name- The cookie name.
- value- The cookie value.
- domain- The cookie domain. You can use- .example.com(with a leading period) if you'd like the cookie to be available to all subdomains of the domain. Note that you cannot set it to a different domain. Defaults to- getRequestHostname()when- null.
- path- The cookie path. If this is- /, then the cookie is available in all pages of the webapp. If this is- /somespecificpath, then the cookie is only available in pages under the specified path.
- maxAge- The maximum age of the cookie, in seconds. If this is- 0, then the cookie will be removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is- -1then the cookie will become a session cookie and thus live as long as the established HTTP session.
- Throws:
- NullPointerException- When faces context is unavailable.
- UnsupportedOperationException- When this platform does not support UTF-8.
- Since:
- 1.8
- See Also:
- ExternalContext.addResponseCookie(String, String, Map)
 
 - 
addResponseCookiepublic static void addResponseCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly) Add a cookie with given name, value, domain, path, maxage and HttpOnly flag to the HTTP response. The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored. The cookie will implicitly be set to secure when the current request is a HTTPS request.- Parameters:
- name- The cookie name.
- value- The cookie value.
- domain- The cookie domain. You can use- .example.com(with a leading period) if you'd like the cookie to be available to all subdomains of the domain. Note that you cannot set it to a different domain. Defaults to- getRequestHostname()when- null.
- path- The cookie path. If this is- /, then the cookie is available in all pages of the webapp. If this is- /somespecificpath, then the cookie is only available in pages under the specified path.
- maxAge- The maximum age of the cookie, in seconds. If this is- 0, then the cookie will be removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is- -1then the cookie will become a session cookie and thus live as long as the established HTTP session.
- httpOnly- When set to true, then JavaScript is not allowed to manipulate the cookie.
- Throws:
- NullPointerException- When faces context is unavailable.
- UnsupportedOperationException- When this platform does not support UTF-8.
- Since:
- 3.3
- See Also:
- ExternalContext.addResponseCookie(String, String, Map)
 
 - 
addResponseCookiepublic static void addResponseCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly, Map<String,String> attributes) Add a cookie with given name, value, domain, path, maxage, HttpOnly flag and custom attributes to the HTTP response. The cookie value will implicitly be URL-encoded with UTF-8 so that any special characters can be stored. The cookie will implicitly be set to secure when the current request is a HTTPS request.- Parameters:
- name- The cookie name.
- value- The cookie value.
- domain- The cookie domain. You can use- .example.com(with a leading period) if you'd like the cookie to be available to all subdomains of the domain. Note that you cannot set it to a different domain. Defaults to- getRequestHostname()when- null.
- path- The cookie path. If this is- /, then the cookie is available in all pages of the webapp. If this is- /somespecificpath, then the cookie is only available in pages under the specified path.
- maxAge- The maximum age of the cookie, in seconds. If this is- 0, then the cookie will be removed. Note that the name and path must be exactly the same as it was when the cookie was created. If this is- -1then the cookie will become a session cookie and thus live as long as the established HTTP session.
- httpOnly- When set to true, then JavaScript is not allowed to manipulate the cookie.
- attributes- Any custom attributes you'd like to add to the cookie, such as- SameSite:None. Any key whose name matches a predefined cookie attribute name, such as- domain,- path,- HttpOnly, etc, will override them. If the underlying Faces and/or Servlet implementation does not allow a certain custom attribute, then it will throw- IllegalArgumentException.
- Throws:
- NullPointerException- When faces context is unavailable.
- UnsupportedOperationException- When this platform does not support UTF-8.
- IllegalArgumentException- When a custom attribute is specified which is not supported by the underlying Faces and/or Servlet implementation. As of now, it's only supported when running minimally Faces 4 on on top of minimally Servlet 6.
- Since:
- 4.0
- See Also:
- ExternalContext.addResponseCookie(String, String, Map)
 
 - 
removeResponseCookiepublic static void removeResponseCookie(String name, String path) Remove the cookie with given name and path from the HTTP response. Note that the name and path must be exactly the same as it was when the cookie was created.- Parameters:
- name- The cookie name.
- path- The cookie path.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.addResponseCookie(String, String, Map)
 
 - 
getSessionpublic static HttpSession getSession() Returns the HTTP session and creates one if one doesn't exist.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- The HTTP session.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getSession(boolean)
 
 - 
getSessionpublic static HttpSession getSession(boolean create) Returns the HTTP session and creates one if one doesn't exist andcreateargument istrue, otherwise don't create one and returnnull.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Parameters:
- create- Whether or not to create a new session if one doesn't exist.
- Returns:
- The HTTP session.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getSession(boolean)
 
 - 
getSessionIdpublic static String getSessionId() Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.- Returns:
- The HTTP session ID.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.2
- See Also:
- HttpSession.getId()
 
 - 
invalidateSessionpublic static void invalidateSession() Invalidates the current HTTP session. So, any subsequent HTTP request will get a new one when necessary.- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.invalidateSession()
 
 - 
hasSessionpublic static boolean hasSession() Returns whether the HTTP session has already been created.- Returns:
- trueif the HTTP session has already been created, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.getSession(boolean)
 
 - 
isSessionNewpublic static boolean isSessionNew() Returns whether the HTTP session has been created for the first time in the current request. This returns alsofalsewhen there is no means of a HTTP session.- Returns:
- trueif the HTTP session has been created for the first time in the current request, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.getSession(boolean),- HttpSession.isNew()
 
 - 
isRequestedSessionExpiredpublic static boolean isRequestedSessionExpired() Returns whether the requested HTTP session is expired.This is also available in EL as #{faces.requestedSessionExpired}.- Returns:
- trueif the requested HTTP session is expired, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.13
- See Also:
- HttpServletRequest.getRequestedSessionId(),- HttpServletRequest.isRequestedSessionIdValid()
 
 - 
getSessionCreationTimepublic static long getSessionCreationTime() Returns the time when the HTTP session was created, measured in epoch time. This implicitly creates the session if one doesn't exist.- Returns:
- The time when the HTTP session was created.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpSession.getCreationTime()
 
 - 
getSessionLastAccessedTimepublic static long getSessionLastAccessedTime() Returns the time of the previous request associated with the current HTTP session, measured in epoch time. This implicitly creates the session if one doesn't exist.- Returns:
- The time of the previous request associated with the current HTTP session.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpSession.getLastAccessedTime()
 
 - 
getSessionMaxInactiveIntervalpublic static int getSessionMaxInactiveInterval() Returns the HTTP session timeout in seconds. This implicitly creates the session if one doesn't exist.- Returns:
- The HTTP session timeout in seconds.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.getSessionMaxInactiveInterval()
 
 - 
setSessionMaxInactiveIntervalpublic static void setSessionMaxInactiveInterval(int seconds) Sets the HTTP session timeout in seconds. A value of 0 or less means that the session should never timeout. This implicitly creates the session if one doesn't exist.- Parameters:
- seconds- The HTTP session timeout in seconds.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.setSessionMaxInactiveInterval(int)
 
 - 
hasSessionTimedOut@Deprecated(since="4.5", forRemoval=true) public static boolean hasSessionTimedOut() Deprecated, for removal: This API element is subject to removal in a future version.UseisRequestedSessionExpired()instead.Returns whether the HTTP session has been timed out for the current request. This is helpful if you need to distinguish between a first-time request on a fresh session and a first-time request on a timed out session, for example to display "Oops, you have been logged out because your session has been timed out!".- Returns:
- trueif the HTTP session has been timed out for the current request, otherwise- false.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- HttpServletRequest.getRequestedSessionId(),- HttpServletRequest.isRequestedSessionIdValid()
 
 - 
getServletContextpublic static ServletContext getServletContext() Returns the servlet context.Note that whenever you absolutely need this method to perform a general task, you might want to consider to submit a feature request to OmniFaces in order to add a new utility method which performs exactly this general task. - Returns:
- the servlet context.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getContext()
 
 - 
getInitParameterMappublic static Map<String,String> getInitParameterMap() Returns the application initialization parameter map. This returns the parameter name-value pairs of all<context-param>entries in inweb.xml.- Returns:
- The application initialization parameter map.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.getInitParameterMap()
 
 - 
getInitParameterpublic static String getInitParameter(String name) Returns the application initialization parameter. This returns the<param-value>of a<context-param>inweb.xmlassociated with the given<param-name>.- Parameters:
- name- The application initialization parameter name.
- Returns:
- The application initialization parameter value associated with the given name, or nullif there is none.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.1
- See Also:
- ExternalContext.getInitParameter(String)
 
 - 
getInitParameterOrDefaultpublic static String getInitParameterOrDefault(String name, String defaultValue) Returns the application initialization parameter. This returns the<param-value>of a<context-param>inweb.xmlassociated with the given<param-name>.- Parameters:
- name- The application initialization parameter name.
- defaultValue- The default value if there is no application initialization parameter value associated with the given name.
- Returns:
- The application initialization parameter value associated with the given name, or defaultValueif there is none.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 3.1
- See Also:
- ExternalContext.getInitParameter(String)
 
 - 
getMimeTypepublic static String getMimeType(String name) Returns the mime type for the given file name. The mime type is determined based on file extension and configureable by<mime-mapping>entries inweb.xml. When the mime type is unknown, then a default ofapplication/octet-streamwill be returned.- Parameters:
- name- The file name to return the mime type for.
- Returns:
- The mime type for the given file name.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getMimeType(String)
 
 - 
getResourcepublic static URL getResource(String path) throws MalformedURLException Returns a URL for an application resource mapped to the specified path, if it exists; otherwise, returnnull.- Parameters:
- path- The application resource path to return an input stream for.
- Returns:
- An input stream for an application resource mapped to the specified path.
- Throws:
- NullPointerException- When faces context is unavailable.
- MalformedURLException- When the specified path is not in correct URL form.
- Since:
- 1.2
- See Also:
- ExternalContext.getResource(String)
 
 - 
getResourceAsStreampublic static InputStream getResourceAsStream(String path) Returns an input stream for an application resource mapped to the specified path, if it exists; otherwise, returnnull.- Parameters:
- path- The application resource path to return an input stream for.
- Returns:
- An input stream for an application resource mapped to the specified path.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getResourceAsStream(String)
 
 - 
getResourcePathspublic static Set<String> getResourcePaths(String path) Returns a set of available application resource paths matching the specified path.- Parameters:
- path- The partial application resource path used to return matching resource paths.
- Returns:
- A set of available application resource paths matching the specified path.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getResourcePaths(String)
 
 - 
getRealPathpublic static String getRealPath(String webContentPath) Returns the absolute disk file system path representation of the given web content path. This thus converts the given path of a web content resource (e.g./index.xhtml) to an absolute disk file system path (e.g./path/to/server/work/folder/some.war/index.xhtml) which can then be used inFile,FileInputStream, etc.Note that this will return nullwhen the WAR is not expanded into the disk file system, but instead into memory. If all you want is just anInputStreamof the web content resource, then better usegetResourceAsStream(String)instead.Also note that it wouldn't make sense to modify or create files in this location, as those changes would get lost anyway when the WAR is redeployed or even when the server is restarted. This is thus absolutely not a good location to store for example uploaded files. - Parameters:
- webContentPath- The web content path to be converted to an absolute disk file system path.
- Returns:
- The absolute disk file system path representation of the given web content path.
- Throws:
- NullPointerException- When faces context is unavailable.
- Since:
- 1.2
 
 - 
getRequestMappublic static Map<String,Object> getRequestMap() Returns the request scope map.- Returns:
- The request scope map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestMap()
 
 - 
getRequestAttributepublic static <T> T getRequestAttribute(String name) Returns the request scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The request scope attribute name.
- Returns:
- The request scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- See Also:
- ExternalContext.getRequestMap()
 
 - 
getRequestAttributepublic static <T> T getRequestAttribute(String name, Supplier<T> computeIfAbsent) Returns the request scope attribute value associated with the given name, or computes the supplied value if absent.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The request scope attribute name.
- computeIfAbsent- The computed request scope attribute value when absent. Useful if it represents a collection, map or bean.
- Returns:
- The request scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.0
- See Also:
- ExternalContext.getRequestMap()
 
 - 
setRequestAttributepublic static void setRequestAttribute(String name, Object value) Sets the request scope attribute value associated with the given name.- Parameters:
- name- The request scope attribute name.
- value- The request scope attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getRequestMap()
 
 - 
removeRequestAttributepublic static <T> T removeRequestAttribute(String name) Removes the request scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The request scope attribute name.
- Returns:
- The request scope attribute value previously associated with the given name, or nullif there is no such attribute.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.1
- See Also:
- ExternalContext.getRequestMap()
 
 - 
getFlashpublic static Flash getFlash() Returns the flash scope. Note thatFlashimplementsMap<String, Object>, so you can just treat it like aMap<String, Object>.- Returns:
- The flash scope.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getFlash()
 
 - 
getFlashAttributepublic static <T> T getFlashAttribute(String name) Returns the flash scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The flash scope attribute name.
- Returns:
- The flash scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- See Also:
- ExternalContext.getFlash()
 
 - 
getFlashAttributepublic static <T> T getFlashAttribute(String name, Supplier<T> computeIfAbsent) Returns the flash scope attribute value associated with the given name, or computes the supplied value if absent.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The flash scope attribute name.
- computeIfAbsent- The computed flash scope attribute value when absent. Useful if it represents a collection, map or bean.
- Returns:
- The flash scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.0
- See Also:
- ExternalContext.getFlash()
 
 - 
setFlashAttributepublic static void setFlashAttribute(String name, Object value) Sets the flash scope attribute value associated with the given name.- Parameters:
- name- The flash scope attribute name.
- value- The flash scope attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getFlash()
 
 - 
removeFlashAttributepublic static <T> T removeFlashAttribute(String name) Removes the flash scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The flash scope attribute name.
- Returns:
- The flash scope attribute value previously associated with the given name, or nullif there is no such attribute.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.1
- See Also:
- ExternalContext.getFlash()
 
 - 
getViewMappublic static Map<String,Object> getViewMap() Returns the view scope map.- Returns:
- The view scope map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- UIViewRoot.getViewMap()
 
 - 
getViewAttributepublic static <T> T getViewAttribute(String name) Returns the view scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The view scope attribute name.
- Returns:
- The view scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- See Also:
- UIViewRoot.getViewMap()
 
 - 
getViewAttributepublic static <T> T getViewAttribute(String name, Supplier<T> computeIfAbsent) Returns the view scope attribute value associated with the given name, or computes the supplied value if absent.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The view scope attribute name.
- computeIfAbsent- The computed view scope attribute value when absent. Useful if it represents a collection, map or bean.
- Returns:
- The view scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.0
- See Also:
- UIViewRoot.getViewMap()
 
 - 
setViewAttributepublic static void setViewAttribute(String name, Object value) Sets the view scope attribute value associated with the given name.- Parameters:
- name- The view scope attribute name.
- value- The view scope attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- UIViewRoot.getViewMap()
 
 - 
removeViewAttributepublic static <T> T removeViewAttribute(String name) Removes the view scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The view scope attribute name.
- Returns:
- The view scope attribute value previously associated with the given name, or nullif there is no such attribute.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.1
- See Also:
- UIViewRoot.getViewMap()
 
 - 
getSessionMappublic static Map<String,Object> getSessionMap() Returns the session scope map.- Returns:
- The session scope map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getSessionMap()
 
 - 
getSessionAttributepublic static <T> T getSessionAttribute(String name) Returns the session scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The session scope attribute name.
- Returns:
- The session scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- See Also:
- ExternalContext.getSessionMap()
 
 - 
getSessionAttributepublic static <T> T getSessionAttribute(String name, Supplier<T> computeIfAbsent) Returns the session scope attribute value associated with the given name, or computes the supplied value if absent.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The session scope attribute name.
- computeIfAbsent- The computed session scope attribute value when absent. Useful if it represents a collection, map or bean.
- Returns:
- The session scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.0
- See Also:
- ExternalContext.getSessionMap()
 
 - 
setSessionAttributepublic static void setSessionAttribute(String name, Object value) Sets the session scope attribute value associated with the given name.- Parameters:
- name- The session scope attribute name.
- value- The session scope attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getSessionMap()
 
 - 
removeSessionAttributepublic static <T> T removeSessionAttribute(String name) Removes the session scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The session scope attribute name.
- Returns:
- The session scope attribute value previously associated with the given name, or nullif there is no such attribute.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.1
- See Also:
- ExternalContext.getSessionMap()
 
 - 
getApplicationMappublic static Map<String,Object> getApplicationMap() Returns the application scope map.- Returns:
- The application scope map.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getApplicationMap()
 
 - 
getApplicationAttributepublic static <T> T getApplicationAttribute(String name) Returns the application scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The application scope attribute name.
- Returns:
- The application scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- See Also:
- ExternalContext.getApplicationMap()
 
 - 
getApplicationAttributepublic static <T> T getApplicationAttribute(String name, Supplier<T> computeIfAbsent) Returns the application scope attribute value associated with the given name, or computes the supplied value if absent.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The application scope attribute name.
- computeIfAbsent- The computed application scope attribute value when absent. Useful if it represents a collection, map or bean.
- Returns:
- The application scope attribute value associated with the given name.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 3.0
- See Also:
- ExternalContext.getApplicationMap()
 
 - 
setApplicationAttributepublic static void setApplicationAttribute(String name, Object value) Sets the application scope attribute value associated with the given name.- Parameters:
- name- The application scope attribute name.
- value- The application scope attribute value.
- Throws:
- NullPointerException- When faces context is unavailable.
- See Also:
- ExternalContext.getApplicationMap()
 
 - 
removeApplicationAttributepublic static <T> T removeApplicationAttribute(String name) Removes the application scope attribute value associated with the given name.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- The application scope attribute name.
- Returns:
- The application scope attribute value previously associated with the given name, or nullif there is no such attribute.
- Throws:
- NullPointerException- When faces context is unavailable.
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.1
- See Also:
- ExternalContext.getApplicationMap()
 
 - 
sendFilepublic static void sendFile(File file, boolean attachment) throws IOException Send the given file to the response. The file name will be derived fromFile.getName(). The content type will be determined based on file name. The content length will be set to the length of the file. TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- file- The file to be sent to the response.
- attachment- Whether the file should be provided as attachment, or just inline.
- Throws:
- NullPointerException- When faces context is unavailable.
- IOException- When given file cannot be read.
- UncheckedIOException- When HTTP response is not available anymore.
 
 - 
sendFilepublic static void sendFile(File file, String filename, boolean attachment) throws IOException Send the given file to the response. The content type will be determined based on file name. The content length will be set to the length of the file. TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- file- The file to be sent to the response.
- filename- The file name which should appear in content disposition header.
- attachment- Whether the file should be provided as attachment, or just inline.
- Throws:
- NullPointerException- When faces context is unavailable.
- IOException- When given file cannot be read.
- UncheckedIOException- When HTTP response is not available anymore.
- Since:
- 3.9
 
 - 
sendFilepublic static void sendFile(Path path, boolean attachment) throws IOException Send the given path as a file to the response. The file will be derived fromPath.toFile()and then the file name will be derived fromFile.getName(). The content type will be determined based on file name. The content length will be set to the length of the file. TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- path- The path to be sent as a file to the response.
- attachment- Whether the file should be provided as attachment, or just inline.
- Throws:
- NullPointerException- When faces context is unavailable.
- IOException- When given file cannot be read.
- UncheckedIOException- When HTTP response is not available anymore.
- Since:
- 3.9
 
 - 
sendFilepublic static void sendFile(Path path, String filename, boolean attachment) throws IOException Send the given path as a file to the response. The file will be derived fromPath.toFile(). The content type will be determined based on file name. The content length will be set to the length of the file. TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- path- The path to be sent as a file to the response.
- filename- The file name which should appear in content disposition header.
- attachment- Whether the file should be provided as attachment, or just inline.
- Throws:
- NullPointerException- When faces context is unavailable.
- IOException- When given file cannot be read.
- UncheckedIOException- When HTTP response is not available anymore.
- Since:
- 3.9
 
 - 
sendFilepublic static void sendFile(byte[] content, String filename, boolean attachment)Send the given byte array as a file to the response. The content type will be determined based on file name. The content length will be set to the length of the byte array. TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- content- The file content as byte array.
- filename- The file name which should appear in content disposition header.
- attachment- Whether the file should be provided as attachment, or just inline.
- Throws:
- NullPointerException- When faces context is unavailable.
- UncheckedIOException- When HTTP response is not available anymore.
 
 - 
sendFilepublic static void sendFile(InputStream content, String filename, boolean attachment) Send the given input stream as a file to the response. The content type will be determined based on file name. The content length may not be set because that's not predictable based on input stream. The client may receive a download of an unknown length and thus the download progress may be unknown to the client. Only if the input stream is smaller than the default buffer size, then the content length will be set. TheInputStream.close()will implicitly be called after streaming, regardless of whether an exception is been thrown or not. TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- content- The file content as input stream.
- filename- The file name which should appear in content disposition header.
- attachment- Whether the file should be provided as attachment, or just inline.
- Throws:
- NullPointerException- When faces context is unavailable.
- UncheckedIOException- When HTTP response is not available anymore.
 
 - 
sendFilepublic static void sendFile(String filename, boolean attachment, FunctionalInterfaces.ThrowingConsumer<OutputStream> outputCallback) Send a file to the response whose content is provided via given output stream callback. The content type will be determined based on file name. The content length will not be set because that would require buffering the entire file in memory or temp disk. The client may receive a download of an unknown length and thus the download progress may be unknown to the client. If this is undesirable, write to a temp file instead and then usesendFile(File, boolean). TheFacesContext.responseComplete()will implicitly be called after successful streaming.- Parameters:
- filename- The file name which should appear in content disposition header.
- attachment- Whether the file should be provided as attachment, or just inline.
- outputCallback- The output stream callback to write the file content to.
- Throws:
- NullPointerException- When faces context is unavailable.
- UncheckedIOException- When HTTP response is not available anymore.
- Since:
- 2.3
 
 
- 
 
-