1 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 35 public class ExceptionService implements IEngineService 36 { 37 private WebRequest _request; 38 39 private WebResponse _response; 40 41 private PortletRequestGlobals _globals; 42 43 public ILink getLink(IRequestCycle cycle, Object parameter) 44 { 45 throw new UnsupportedOperationException (PortletMessages.unsupportedMethod("getLink")); 46 } 47 48 public void service(IRequestCycle cycle) throws IOException 49 { 50 WebSession session = _request.getSession(true); 51 String markup = (String ) session 52 .getAttribute(PortletConstants.PORTLET_EXCEPTION_MARKUP_ATTRIBUTE); 53 54 PrintWriter writer = _response.getPrintWriter(new ContentType("text/html")); 55 56 PortletURL url = _globals.getRenderResponse().createActionURL(); 57 58 writer.println("<span class=\"portlet-msg-error\">An exception has occured.</span>"); 59 writer.println("<br/>"); 60 writer.println("<a HREF=\"" + url.toString() + "\">Click here to continue</a>"); 61 writer.print("<br/><hr/>"); 62 writer.println(); 63 64 writer.print(markup); 65 } 66 67 public String getName() 68 { 69 return PortletConstants.EXCEPTION_SERVICE; 70 } 71 72 public void setRequest(WebRequest request) 73 { 74 _request = request; 75 } 76 77 public void setResponse(WebResponse response) 78 { 79 _response = response; 80 } 81 82 public void setGlobals(PortletRequestGlobals globals) 83 { 84 _globals = globals; 85 } 86 } | Popular Tags |