JavaServer Faces: Web App Scopes - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

JavaServer Faces: Web App Scopes

Description:

As long as a user stays on a page, the component values are remembered even when ... http://www.netbeans.org/kb/55/vwp-scopes.html. Language Voting Web App (cont'd) ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 7
Provided by: acsI
Category:

less

Transcript and Presenter's Notes

Title: JavaServer Faces: Web App Scopes


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., users 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
  • The web application instantiates a managed bean
    the first time, within that bean's scope, that a
    page accesses a property in the managed bean. For
    example, an instance of a SessionBean1 object
    does not exist for the user's session until the
    user accesses a page that references a
    SessionBean1 property.

5
Language Voting Web App
  • http//www.netbeans.org/kb/55/vwp-scopes.html

6
Language Voting Web App (contd)
Write a Comment
User Comments (0)
About PowerShow.com