Author(s)Jonathan Locke, Eelco Hillenius, Igor Vaynberg (ivaynberg)
Holds information about a user session, including some fixed number of most
recent pages (and all their nested component information).
Access via RequestCycle - The Session for a RequestCycle
can be retrieved by calling getSession() .
Access via Component - If a RequestCycle object is not available,
the Session can be retrieved for a Component by calling
getSession() . As currently implemented, each Component
does not itself have a reference to the session that contains it. However,
the Page component at the root of the containment hierarchy does have a
reference to the Session that holds the Page. So
getSession() traverses the component hierarchy to the root
Page and then calls getSession() .
Access via Thread Local - In the odd case where neither a
RequestCycle nor a Component is available, the currently active Session for
the calling thread can be retrieved by calling the static method
Session.get(). This last form should only be used if the first two forms
cannot be used since thread local access can involve a potentially more
expensive hash map lookup.
Locale - A session has a Locale property to support localization.
The Locale for a session can be set by calling
setLocale(Locale) . The Locale for a Session determines how
localized resources are found and loaded.
Style - Besides having an appearance based on locale, resources
can also have different looks in the same locale (a.k.a. "skins"). The style
for a session determines the look which is used within the appopriate locale.
The session style ("skin") can be set with the setStyle() method.
Resource Loading - Based on the Session locale and style,
searching for resources occurs in the following order (where sourcePath is
set via the ApplicationSettings object for the current Application, and style
and locale are Session properties):
Session Properties - Arbitrary objects can be attached to a
Session by installing a session factory on your Application class which
creates custom Session subclasses that have typesafe properties specific to
the application (see Application for details). To discourage
non-typesafe access to Session properties, no setProperty() or getProperty()
method is provided. In a clustered environment, you should take care to call
the dirty() method when you change a property or youre own. This way the
session will be reset again in the http session so that the http session
knows the session is changed.
Class Resolver - Sessions have a class resolver (
IClassResolver ) implementation that is used to locate classes for
components such as pages.
Page Factory - A pluggable implementation of IPageFactory
is used to instantiate pages for the session.
Removal - Pages can be removed from the Session forcibly by
calling remove(Page) or removeAll(), although such an action should rarely be
necessary.
Flash Messages- Flash messages are messages that are stored in
session and are removed after they are displayed to the user. Session acts as
a store for these messages because they can last across requests.
1. [sourcePath]/name[style][locale].[extension]
2. [sourcePath]/name[locale].[extension]
3. [sourcePath]/name[style].[extension]
4. [sourcePath]/name.[extension]
5. [classPath]/name[style][locale].[extension]
6. [classPath]/name[locale].[extension]
7. [classPath]/name[style].[extension]
8. [classPath]/name.[extension]