Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StaleLinkExceptionPresenterImpl |
|
| 1.0;1 |
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.error; | |
16 | ||
17 | import java.io.IOException; | |
18 | ||
19 | import org.apache.hivemind.util.PropertyUtils; | |
20 | import org.apache.tapestry.IPage; | |
21 | import org.apache.tapestry.IRequestCycle; | |
22 | import org.apache.tapestry.StaleLinkException; | |
23 | import org.apache.tapestry.services.ResponseRenderer; | |
24 | ||
25 | /** | |
26 | * Implementation of | |
27 | * {@link org.apache.tapestry.error.StaleLinkExceptionPresenter} that uses a | |
28 | * page to present the exception. The page must implement a property named | |
29 | * "message" of type String and should present that message to the user. | |
30 | * | |
31 | * @author Howard M. Lewis Ship | |
32 | * @since 4.0 | |
33 | */ | |
34 | 0 | public class StaleLinkExceptionPresenterImpl implements StaleLinkExceptionPresenter |
35 | { | |
36 | private ResponseRenderer _responseRenderer; | |
37 | ||
38 | private String _pageName; | |
39 | ||
40 | public void presentStaleLinkException(IRequestCycle cycle, StaleLinkException cause) | |
41 | throws IOException | |
42 | { | |
43 | 0 | IPage exceptionPage = cycle.getPage(_pageName); |
44 | ||
45 | 0 | PropertyUtils.write(exceptionPage, "message", cause.getMessage()); |
46 | ||
47 | 0 | cycle.activate(exceptionPage); |
48 | ||
49 | 0 | _responseRenderer.renderResponse(cycle); |
50 | 0 | } |
51 | ||
52 | public void setPageName(String pageName) | |
53 | { | |
54 | 0 | _pageName = pageName; |
55 | 0 | } |
56 | ||
57 | public void setResponseRenderer(ResponseRenderer responseRenderer) | |
58 | { | |
59 | 0 | _responseRenderer = responseRenderer; |
60 | 0 | } |
61 | ||
62 | } |