|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ExceptionService.java | - | 0% | 0% | 0% |
|
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.portlet; | |
16 | ||
17 | import java.io.IOException; | |
18 | import java.io.PrintWriter; | |
19 | ||
20 | import javax.portlet.PortletURL; | |
21 | ||
22 | import org.apache.tapestry.IRequestCycle; | |
23 | import org.apache.tapestry.engine.IEngineService; | |
24 | import org.apache.tapestry.engine.ILink; | |
25 | import org.apache.tapestry.util.ContentType; | |
26 | import org.apache.tapestry.web.WebRequest; | |
27 | import org.apache.tapestry.web.WebResponse; | |
28 | import org.apache.tapestry.web.WebSession; | |
29 | ||
30 | /** | |
31 | * @author Howard M. Lewis Ship | |
32 | * @since 4.0 | |
33 | * @see org.apache.tapestry.portlet.PortletConstants#PORTLET_EXCEPTION_MARKUP_ATTRIBUTE | |
34 | */ | |
35 | public class ExceptionService implements IEngineService | |
36 | { | |
37 | private WebRequest _request; | |
38 | ||
39 | private WebResponse _response; | |
40 | ||
41 | private PortletRequestGlobals _globals; | |
42 | ||
43 | 0 | public ILink getLink(IRequestCycle cycle, Object parameter) |
44 | { | |
45 | 0 | throw new UnsupportedOperationException(PortletMessages.unsupportedMethod("getLink")); |
46 | } | |
47 | ||
48 | 0 | public void service(IRequestCycle cycle) throws IOException |
49 | { | |
50 | 0 | WebSession session = _request.getSession(true); |
51 | 0 | String markup = (String) session |
52 | .getAttribute(PortletConstants.PORTLET_EXCEPTION_MARKUP_ATTRIBUTE); | |
53 | ||
54 | 0 | PrintWriter writer = _response.getPrintWriter(new ContentType("text/html")); |
55 | ||
56 | 0 | PortletURL url = _globals.getRenderResponse().createActionURL(); |
57 | ||
58 | 0 | writer.println("<span class=\"portlet-msg-error\">An exception has occured.</span>"); |
59 | 0 | writer.println("<br/>"); |
60 | 0 | writer.println("<a href=\"" + url.toString() + "\">Click here to continue</a>"); |
61 | 0 | writer.print("<br/><hr/>"); |
62 | 0 | writer.println(); |
63 | ||
64 | 0 | writer.print(markup); |
65 | } | |
66 | ||
67 | 0 | public String getName() |
68 | { | |
69 | 0 | return PortletConstants.EXCEPTION_SERVICE; |
70 | } | |
71 | ||
72 | 0 | public void setRequest(WebRequest request) |
73 | { | |
74 | 0 | _request = request; |
75 | } | |
76 | ||
77 | 0 | public void setResponse(WebResponse response) |
78 | { | |
79 | 0 | _response = response; |
80 | } | |
81 | ||
82 | 0 | public void setGlobals(PortletRequestGlobals globals) |
83 | { | |
84 | 0 | _globals = globals; |
85 | } | |
86 | } |
|