1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.contrib.ajax; |
16 |
| |
17 |
| import java.util.HashMap; |
18 |
| import java.util.Map; |
19 |
| |
20 |
| import javax.servlet.http.HttpSession; |
21 |
| |
22 |
| import org.apache.tapestry.BaseComponent; |
23 |
| import org.apache.tapestry.IRequestCycle; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| public abstract class Timeout extends BaseComponent { |
30 |
| public abstract int getWarningTime(); |
31 |
| public abstract int getAutoProlongTime(); |
32 |
| |
33 |
| public abstract String getWarningMessage(); |
34 |
| public abstract String getExpirationMessage(); |
35 |
| |
36 |
| public abstract boolean getDisableWarning(); |
37 |
| public abstract boolean getDisableAutoProlong(); |
38 |
| |
39 |
| public abstract String getExpirationFunction(); |
40 |
| |
41 |
0
| protected HttpSession getSession()
|
42 |
| { |
43 |
0
| return getPage().getRequestCycle().getRequestContext().getSession();
|
44 |
| } |
45 |
| |
46 |
0
| protected int getSessionTime()
|
47 |
| { |
48 |
0
| return getSession().getMaxInactiveInterval();
|
49 |
| } |
50 |
| |
51 |
0
| public boolean isInSession()
|
52 |
| { |
53 |
0
| HttpSession session = getSession();
|
54 |
0
| return session != null;
|
55 |
| } |
56 |
| |
57 |
0
| public Map getScriptSymbols()
|
58 |
| { |
59 |
0
| int nSessionTime = getSessionTime();
|
60 |
0
| int nTimeToMessage = nSessionTime - getWarningTime();
|
61 |
0
| if (nTimeToMessage < 0)
|
62 |
0
| nTimeToMessage = 0;
|
63 |
0
| int nRemainingTime = nSessionTime - nTimeToMessage;
|
64 |
0
| int nAutoProlongTime = nSessionTime - getAutoProlongTime();
|
65 |
| |
66 |
0
| Map mapSymbols = new HashMap();
|
67 |
0
| mapSymbols.put("confirmTimeout", new Integer(nTimeToMessage*1000));
|
68 |
0
| mapSymbols.put("expirationTimeout", new Integer(nRemainingTime*1000));
|
69 |
0
| mapSymbols.put("prolongSessionPeriod", new Integer(nAutoProlongTime*1000));
|
70 |
0
| mapSymbols.put("confirmMessage", getWarningMessage());
|
71 |
0
| mapSymbols.put("expirationMessage", getExpirationMessage());
|
72 |
0
| mapSymbols.put("disableWarning", new Boolean(getDisableWarning()));
|
73 |
0
| mapSymbols.put("disableAutoProlong", new Boolean(getDisableAutoProlong()));
|
74 |
0
| mapSymbols.put("expirationFunction", getExpirationFunction());
|
75 |
0
| return mapSymbols;
|
76 |
| } |
77 |
| |
78 |
0
| public void renewSession(IRequestCycle cycle)
|
79 |
| { |
80 |
| |
81 |
| |
82 |
| } |
83 |
| } |