source: vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/VloSession.java @ 4240

Last change on this file since 4240 was 4240, checked in by twagoo, 10 years ago

Replaced calls getting session (either on component or statically) and casting to VloSession? with new convenience method VloSession?.get()

File size: 2.0 KB
Line 
1package eu.clarin.cmdi.vlo;
2
3import org.apache.wicket.Session;
4import org.apache.wicket.protocol.http.WebSession;
5import org.apache.wicket.request.Request;
6import org.apache.wicket.request.mapper.parameter.PageParameters;
7
8/**
9 * A web session containing a VLO theme and parameters that are considered to be
10 * persistent in a VLO session.
11 *
12 * Note that these parameters can include the specification of the theme.
13 *
14 * @author keeloo
15 */
16public class VloSession extends WebSession {
17
18    // remember the parameters that need to persist in URLs to VLO pages in this session
19    private PageParameters vloSessionPageParameters = new PageParameters();
20
21    // remember this session's theme
22    private Theme currentTheme = new Theme("defaultTheme");
23
24    /**
25     * Construct a session object with a request parameter
26     *
27     * @param request
28     */
29    public VloSession(Request request) {
30        // only the parameterless constructors are invoked implicitly
31        super(request);
32    }
33
34    /**
35     * Get the session's theme
36     *
37     * @return the session's theme
38     */
39    public Theme getCurrentTheme() {
40        return this.currentTheme;
41    }
42
43    /**
44     * Set the session's theme
45     *
46     * @param theme the session's theme
47     */
48    public void setCurrentTheme(Theme theme) {
49        this.currentTheme = theme;
50    }
51
52    /**
53     * Return the session's persistent parameters
54     *
55     * @return session parameters
56     */
57    public PageParameters getVloSessionPageParameters() {
58        return vloSessionPageParameters;
59    }
60
61    /**
62     * Add parameters to the session's persistent parameters
63     *
64     * @param parameters a page parameter map
65     *
66     */
67    public void addVloSessionPageParameters(PageParameters parameters) {
68
69        vloSessionPageParameters.mergeWith(parameters);
70    }
71
72    /**
73     * @return the VLO session associated to current thread
74     */
75    public static VloSession get() {
76        return (VloSession) Session.get();
77    }
78}
Note: See TracBrowser for help on using the repository browser.