Access via Component - If a RequestCycle object is not available,
the Session can be retrieved for a Component by calling
Component.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
Component.getSession traverses the component hierarchy to the root
Page and then calls
Page.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
Session.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.
author: Jonathan Locke author: Eelco Hillenius author: Igor Vaynberg (ivaynberg)
Inner Class :public static interface IPageMapVisitor
Removes all pages from the session. Although this method should rarely be
needed, it is available (possibly for security reasons).
createAutoPageMap
final public synchronized PageMap createAutoPageMap()(Code)
Automatically creates a page map, giving it a session unique name.
Created PageMap
createAutoPageMapName
final public synchronized String createAutoPageMapName()(Code)
With this call you can create a pagemap name but not create the pagemap
itself already. It will give the first pagemap name where it couldn't
find a current pagemap for.
It will return the same name if you call it 2 times in a row.
The created pagemap name
Any detach logic for session subclasses. This is called on the end of
handling a request, when the RequestCycle is about to be detached from
the current thread.
Gets the client info object for this session. This method lazily gets the
new agent info object for this session. It uses any cached or set (
Session.setClientInfo(ClientInfo) )
client info object or uses
RequestCycle.newClientInfo to get
the info object based on the current request when no client info object
was set yet, and then caches the returned object; we can expect the
client to stay the same for the whole session, and implementations of
RequestCycle.newClientInfo might be relatively expensive.
the client info object based on this request
Gets the converter instance. This method returns the cached converter for
the current locale. Whenever the locale is changed, the cached value is
cleared and the converter will be recreated for the new locale on a next
request.
the converter
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
Get the page for the given path.
Parameters: pageMapName - The name of the page map where the page is Parameters: path - Component path Parameters: versionNumber - The version of the page required The page based on the first path component (the page id), or nullif the requested version of the page cannot be found.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
Creates a new RequestCycle for the given request and response using the
session's request cycle factory.
Parameters: request - The request Parameters: response - The response The new request cycle.
pageMapForName
final publicPageMap pageMapForName(String pageMapName, boolean autoCreate)(Code)
Gets a page map for the given name, automatically creating it if need be.
Parameters: pageMapName - Name of page map, or null for default page map Parameters: autoCreate - True if the page map should be automatically created if itdoes not exist PageMap for name
removeAttribute
final protected void removeAttribute(String name)(Code)
Removes the attribute with the given name.
Parameters: name - the name of the attribute to remove
removePageMap
final public void removePageMap(PageMap pageMap)(Code)
Adds or replaces the attribute with the given name and value.
Parameters: name - The name of the attribute Parameters: value - The value of the attribute
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
Sets the client info object for this session. This will only work when
Session.getClientInfo() is not overriden.
Parameters: clientInfo - the client info object
Sets the metadata for this session using the given key. If the metadata
object is not of the correct type for the metadata key, an
IllegalArgumentException will be thrown. For information on creating
MetaDataKeys, see
MetaDataKey .
Parameters: key - The singleton key for the metadata Parameters: object - The metadata object throws: IllegalArgumentException - See Also:MetaDataKey
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
The page will be 'touched' in the session. If it wasn't added yet to the
pagemap, it will be added to the page map else it will set this page to
the front.
If another page was removed because of this it will be cleaned up.
Parameters: page -