Java EE 8 By Example
  • Introduction
  • Overview
    • Example Codes
  • JSF 2.3
    • Activating CDI in JSF 2.3
    • Run applications in JSF 2.2 compatible mode
    • CDI alignment
    • CDI compatible @ManagedProperty
    • Inject support in Converter, Validator and Behavor
    • Websocket support
    • UIData improvements
    • Class level bean validation with f:valdiateWholeBean
    • Java 8 DateTime support
    • PostRenderViewEvent: publising events after view is rendered
    • Search expression framework
  • CDI 2.0
    • Java SE support
    • Event Priority
    • Async Events
    • Register Beans dynamicially
    • Configurators and Intercept Producers
  • JPA 2.2
    • Java 8 Datetime support
    • Return Stream based result from Query
    • More CDI Alignments
  • JSON-B 1.0
  • JSON-P 1.1
  • Bean Validation 2.0
  • JAXRS 2.1
    • Async improvements
    • Server Sent Event
    • Reactive Client
  • Java EE Security API 1.0
    • HttpAuthenticationMechanism
    • IdentityStore
    • SecurityContext
  • Servlet 4.0
    • Server Push
    • Runtime Discovery of Servlet Mappings
    • Http Trailer
  • MVC 1.0
    • Getting started with MVC
    • Handling form submission
    • Exception handling and form validation
    • Processing PUT and DELETE methods
    • Page navigation
    • MVC and CDI
    • Security
    • Bean parameter conversion
    • View engine
Powered by GitBook
On this page

Was this helpful?

  1. JSF 2.3

CDI alignment

JSF 2.2 starts CDI integration, provides built-in CDI compatible ViewScoped and @FlowScoped, and all CDI scopes are compatible with JSF.

In JSF 2.3, more CDI alignments are added.

A lots of JSF built-in facilities are exposed as CDI beans, and can be injected as general CDI beans.

In JSF 2.2, to get JSF facilities.

FacesContext context= FacesContext.getCurrentInstance();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
Map<String, Object> cookieMap = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap();
Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();

In JSF 2.3, you can inject them directly in your backing bean.

@Inject
FacesContext facesContext;

@Inject
ExternalContext externalContext;

@Inject
@RequestCookieMap
Map<String, Object> cookieMap;

@Inject
@ViewMap
Map<String, Object> viewMap;

And all of these can be resolved via EL in facelets template.

Artifact

EL name

Qualifier

Type

Application

#{application}

-

java.lang.Object (javax.servlet.ServletContext)

ApplicationMap

#{applicationScope}

@ApplicationMap

java.util.Map

CompositeComponent

#{cc}

(Not injectable)

javax.faces.component.UIComponent

Component

#{component}

(Not injectable)

javax.faces.component.UIComponent

RequestCookieMap

#{cookie}

@RequestCookieMap

java.util.Map

FacesContext

#{facesContext}

-

javax.faces.context.FacesContext

Flash

#{flash}

-

javax.faces.context.Flash

FlowMap

#{flowScope}

@FlowMap

java.util.Map

HeaderMap

#{header}

@HeaderMap

java.util.Map

HeaderValuesMap

#{headerValues}

@HeaderValuesMap

java.util.Map

InitParameterMap

#{initParam}

@InitParameterMap

java.util.Map

RequestParameterMap

#{param}

@RequestParameterMap

java.util.Map

RequestParameterValuesMap

#{paramValues}

@RequestParameterValuesMap

java.util.Map

Request

#{request}

(Not injectable)

java.lang.Object (javax.servlet.http.HttpServletRequest)

RequestMap

#{requestScope}

@RequestMap

java.util.Map

ResourceHandler

#{"resource"}

-

javax.faces.application.ResourceHandler

Session

#{session}

(Not injectable)

java.lang.Object (javax.servlet.http.HttpSession)

SessionMap

#{sessionScope}

@SessionMap

java.util.Map

View

#{view}

-

javax.faces.component.UIViewRoot

ViewMap

#{viewScope}

@ViewMap

java.util.Map

ExternalContext

#{externalContext} (new)

-

javax.faces.context.ExternalContext

PreviousRun applications in JSF 2.2 compatible modeNextCDI compatible @ManagedProperty

Last updated 4 years ago

Was this helpful?

There is a table listed all supported facilities in Arjan Tijms's blog entry, .

What's new in JSF 2.3?