From the course: Java EE: JavaServer Faces JSF

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Short-lived managed beans

Short-lived managed beans

From the course: Java EE: JavaServer Faces JSF

Start my 1-month free trial

Short-lived managed beans

- [Narrator] Now for the short-lived managed beans. Let's start with a request scope bean. We've already seen the RequestScoped annotation in action. This scope specifies that this backing bean class should be instantiated at the beginning of a JSF page request and then be destroyed right after the request is complete, that is, when the page has completely loaded. An oversimplified way of thinking of it is that the bean is created at the beginning of the JSF request life cycle and is destroyed after the last step. So, this scope is ideal for pages that will display static information, or even a page that displays some dynamic data, but doesn't have too much back and forth between the user and the server. Then, we have my favorite, the view scope. Let's try it out. We go to our package here. We create a new Java class. Let's call this our SampleViewScopedBean. Hit the finish button. There we have our plain Java class. Let's add the @Named annotation, fix the import, and then name it…

Contents