1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.engine; |
16 |
| |
17 |
| import java.io.IOException; |
18 |
| import java.util.HashMap; |
19 |
| import java.util.Map; |
20 |
| |
21 |
| import org.apache.tapestry.IRequestCycle; |
22 |
| import org.apache.tapestry.Tapestry; |
23 |
| import org.apache.tapestry.services.LinkFactory; |
24 |
| import org.apache.tapestry.services.ResetEventCoordinator; |
25 |
| import org.apache.tapestry.services.ResponseRenderer; |
26 |
| import org.apache.tapestry.services.ServiceConstants; |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| public class ResetService implements IEngineService |
39 |
| { |
40 |
| |
41 |
| |
42 |
| private ResponseRenderer _responseRenderer; |
43 |
| |
44 |
| |
45 |
| |
46 |
| private ResetEventCoordinator _resetEventCoordinator; |
47 |
| |
48 |
| |
49 |
| private boolean _enabled; |
50 |
| |
51 |
| |
52 |
| |
53 |
| private LinkFactory _linkFactory; |
54 |
| |
55 |
4
| public ILink getLink(IRequestCycle cycle, boolean post, Object parameter)
|
56 |
| { |
57 |
4
| if (parameter != null)
|
58 |
1
| throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
|
59 |
| |
60 |
3
| Map parameters = new HashMap();
|
61 |
| |
62 |
3
| parameters.put(ServiceConstants.SERVICE, getName());
|
63 |
3
| parameters.put(ServiceConstants.PAGE, cycle.getPage().getPageName());
|
64 |
| |
65 |
3
| return _linkFactory.constructLink(cycle, post, parameters, true);
|
66 |
| } |
67 |
| |
68 |
7
| public String getName()
|
69 |
| { |
70 |
7
| return Tapestry.RESET_SERVICE;
|
71 |
| } |
72 |
| |
73 |
1
| public void service(IRequestCycle cycle) throws IOException
|
74 |
| { |
75 |
1
| String pageName = cycle.getParameter(ServiceConstants.PAGE);
|
76 |
| |
77 |
1
| if (_enabled)
|
78 |
0
| _resetEventCoordinator.fireResetEvent();
|
79 |
| |
80 |
1
| cycle.activate(pageName);
|
81 |
| |
82 |
| |
83 |
| |
84 |
1
| _responseRenderer.renderResponse(cycle);
|
85 |
| } |
86 |
| |
87 |
| |
88 |
2
| public void setResponseRenderer(ResponseRenderer responseRenderer)
|
89 |
| { |
90 |
2
| _responseRenderer = responseRenderer;
|
91 |
| } |
92 |
| |
93 |
| |
94 |
| |
95 |
2
| public void setResetEventCoordinator(ResetEventCoordinator resetEventCoordinator)
|
96 |
| { |
97 |
2
| _resetEventCoordinator = resetEventCoordinator;
|
98 |
| } |
99 |
| |
100 |
| |
101 |
| |
102 |
2
| public void setEnabled(boolean enabled)
|
103 |
| { |
104 |
2
| _enabled = enabled;
|
105 |
| } |
106 |
| |
107 |
| |
108 |
3
| public void setLinkFactory(LinkFactory linkFactory)
|
109 |
| { |
110 |
3
| _linkFactory = linkFactory;
|
111 |
| } |
112 |
| } |