Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaServer Faces: Web App Scopes & Managed Beans Compiled from “Understanding Scope and Managed Beans”

Similar presentations


Presentation on theme: "JavaServer Faces: Web App Scopes & Managed Beans Compiled from “Understanding Scope and Managed Beans”"— Presentation transcript:

1 JavaServer Faces: Web App Scopes & Managed Beans Compiled from “Understanding Scope and Managed Beans” http://www.netbeans.org/kb/55/vwp-scopes.html http://www.netbeans.org/kb/60/web/scopes.html

2 About Scopes As long as a user stays on a page, the component values are remembered even when the page redisplays, such as when the user clicks a button that returns null. (when the user leaves the page, the component values disappear). To make values available to other pages, or to make values available to the same page, should the user return to it, you need to store the values. When you create a project from the IDE, the IDE creates three managed beans for storing values:  RequestBean1  SessionBean1  ApplicationBean1

3 Managed Beans a JavaBeans object that a JSF web application instantiates and stores in either request scope, session scope, or application scope. Before you create a bean property to store a value, you must determine the appropriate scope for the property's value. (Why?) The following figure illustrates the duration of each type of scope.  Application scope lasts until the server stops the application. Values that you store in an application bean are available to every session and every request that uses the same application map. e.g., counter to keep track of all users using the app, drop-down list of measurement types for all to access  Session scope begins when a user first accesses a page in the web application and ends when the session times out due to inactivity, or when the web application invalidates the session, such as, for example, by calling session.invalidate(). e.g., user’s login info, shopping cart  Request scope begins when the user submits the page and ends when the response is fully rendered, whatever page that is. e.g., anything that is only needed in 1 request/response cycle (timestamp in the programming language voting sample app)

4 Managed Beans

5 Language Voting Web App

6 Language Voting Web App (cont’d)


Download ppt "JavaServer Faces: Web App Scopes & Managed Beans Compiled from “Understanding Scope and Managed Beans”"

Similar presentations


Ads by Google