<%...-- * Copyright (C) 2005-2007 Alfresco Software Limited. * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License *as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; ifnot, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *As a special exception to the terms and conditions of version 2.0 of * the GPL, you may redistribute this Program in connection with Free/Libre *and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" --%> <%...@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%...@ taglib uri="/WEB-INF/repo.tld" prefix="r"%> <%...@ page buffer="32kb" contentType="text/html;charset=UTF-8"%> <%...@ page isELIgnored="false"%> <%...@ page import="org.alfresco.web.app.Application"%> <r:page titleId="title_error"> <table cellspacing="0" cellpadding="2" width="100%"> <tr> <%...-- Top level toolbar and company logo area --%> <td width=100%> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td><a href="http://www.alfresco.org" target="new"><img src="<%=request.getContextPath()%>/images/logo/AlfrescoLogo32.png" width=32 height=30 alt="Alfresco" title="Alfresco" border=0 style="padding-right:4px"></a></td> <td><img src="<%=request.getContextPath()%>/images/parts/titlebar_begin.gif" width="10" height="30"></td> <td width=100% style="background-image: url(<%=request.getContextPath()%>/images/parts/titlebar_bg.gif)"> <span class="topToolbarTitle"><%=Application.getMessage(session, "system_error")%></span> </td> <td><img src="<%=request.getContextPath()%>/images/parts/titlebar_end.gif" width="8" height="30"></td> </tr> </table> </td> </tr> <tr> <td> <r:systemError styleClass="errorMessage" detailsStyleClass="mainSubTextSmall" showDetails="false"/> </td> </tr> </table> </r:page>
publicint doStartTag() throws JspException ...{ String errorMessage ="No error currently stored"; String errorDetails ="No details"; // get the error details from the bean, this may be in a portlet // session or a normal servlet session. ErrorBean errorBean =null; RenderRequest renderReq = (RenderRequest)pageContext.getRequest(). getAttribute("javax.portlet.request"); if (renderReq !=null) ...{ PortletSession session = renderReq.getPortletSession(); errorBean = (ErrorBean)session.getAttribute(ErrorBean.ERROR_BEAN_NAME); } else ...{ errorBean = (ErrorBean)pageContext.getSession(). getAttribute(ErrorBean.ERROR_BEAN_NAME); } if (errorBean !=null) ...{ errorMessage = errorBean.getLastErrorMessage(); errorDetails = errorBean.getStackTrace(); } else ...{ // if we reach here the error was caught by the declaration in web.xml so // pull all the information from the request and create the error bean Throwable error = (Throwable)pageContext.getRequest().getAttribute("javax.servlet.error.exception"); String uri = (String)pageContext.getRequest().getAttribute("javax.servlet.error.request_uri"); // create and store the ErrorBean errorBean =new ErrorBean(); pageContext.getSession().setAttribute(ErrorBean.ERROR_BEAN_NAME, errorBean); errorBean.setLastError(error); errorBean.setReturnPage(uri); errorMessage = errorBean.getLastErrorMessage(); errorDetails = errorBean.getStackTrace(); } try ...{ Writer out = pageContext.getOut(); ResourceBundle bundle = Application.getBundle(pageContext.getSession()); out.write("<div"); if (this.styleClass !=null) ...{ out.write(" class='"); out.write(this.styleClass); out.write("'"); } out.write(">"); out.write(errorMessage); out.write("</div>"); // work out initial state boolean hidden =!this.showDetails; String display ="inline"; String toggleTitle ="Hide"; if (hidden) ...{ display ="none"; toggleTitle ="Show"; } // output the script to handle toggling of details out.write("<script language='JavaScript'> "); out.write("var hidden = "); out.write(Boolean.toString(hidden)); out.write("; "); out.write("function toggleDetails() { "); out.write("if (hidden) { "); out.write("document.getElementById('detailsTitle').innerHTML = '"); out.write(bundle.getString(MSG_HIDE_DETAILS)); out.write("<br/><br/>'; "); out.write("document.getElementById('details').style.display = 'inline'; "); out.write("hidden = false; "); out.write("} else { "); out.write("document.getElementById('detailsTitle').innerHTML = '"); out.write(bundle.getString(MSG_SHOW_DETAILS)); out.write("'; "); out.write("document.getElementById('details').style.display = 'none'; "); out.write("hidden = true; "); out.write("} } </script> "); // output the initial toggle state out.write("<br/>"); out.write("<a id='detailsTitle' href='javascript:toggleDetails();'>"); out.write(toggleTitle); out.write(" Details</a>"); out.write("<div style='padding-top:5px;display:"); out.write(display); out.write("' id='details'"); if (this.detailsStyleClass !=null) ...{ out.write(" class='"); out.write(this.detailsStyleClass); out.write("'"); } out.write(">"); out.write(errorDetails); out.write("</div>"); // output a link to return to the application out.write(" <div style='padding-top:16px;'><a href='"); if (Application.inPortalServer()) ...{ RenderResponse renderResp = (RenderResponse)pageContext.getRequest().getAttribute( "javax.portlet.response"); if (renderResp ==null) ...{ thrownew IllegalStateException("RenderResponse object is null"); } PortletURL url = renderResp.createRenderURL(); // NOTE: we don't have to specify the page for the portlet, just the VIEW_ID parameter // being present will cause the current JSF view to be re-displayed url.setParameter("org.apache.myfaces.portlet.MyFacesGenericPortlet.VIEW_ID", "current-view"); out.write(url.toString()); } else ...{ String returnPage =null; if (errorBean !=null) ...{ returnPage = errorBean.getReturnPage(); } if (returnPage ==null) ...{ out.write("javascript:history.back();"); } else ...{ out.write(returnPage); } } out.write("'>"); out.write(bundle.getString(MSG_RETURN_TO_APP)); out.write("</a></div>"); // use External Access Servlet to generate a URL to relogin again // this can be used by the user if the app has got into a total mess if (Application.inPortalServer() ==false) ...{ out.write(" <div style='padding-top:16px;'><a href='"); out.write(((HttpServletRequest)pageContext.getRequest()).getContextPath()); out.write(ExternalAccessServlet.generateExternalURL("logout", null)); out.write("'>"); out.write(bundle.getString(MSG_LOGOUT)); out.write("</a></div>"); } } catch (IOException ioe) ...{ thrownew JspException(ioe); } finally ...{ // clear out the error bean otherwise the next error could be hidden pageContext.getSession().removeAttribute(ErrorBean.ERROR_BEAN_NAME); } return SKIP_BODY; }