From the course: Java EE: Contexts and Dependency Injection
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
CDI scopes and JavaServer Faces
From the course: Java EE: Contexts and Dependency Injection
CDI scopes and JavaServer Faces
- [Instructor] CDI beans come into their own when used in combination with JavaServer Faces. JavaServer Faces is a web tier presentation framework that provides a graphical user interface for event driven user interactions. It binds a user interface to objects accessible via unified expression language. Any CDI bean can be assigned a name and therefore be available for JSF applications to take advantage of. All that is required is to annotate the CDI bean with a named annotation, and it can be referred to directly in a JSF page. Okay, let's go to the IDE and see a simple example. So the simplistic sample of how this works is to display a value of a field of a CDI bean in a web page. So for this, all I need are two things. A bean and a JSF web page. So here I have the user bean. And as you can see it has only one property, and that's the name property. As you can see on line 20, I have already assigned a name to the name field. And let's have a look at the JSF page. I'm referring to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.