1 / 6

JavaServer Faces: Web App Scopes & Managed Beans

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. About Scopes.

Download Presentation

JavaServer Faces: Web App Scopes & Managed Beans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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)

More Related