From: <bra...@us...> - 2007-07-19 21:36:14
|
Revision: 1811 http://archive-access.svn.sourceforge.net/archive-access/?rev=1811&view=rev Author: bradtofel Date: 2007-07-19 13:41:26 -0700 (Thu, 19 Jul 2007) Log Message: ----------- FEATURE: now allows configuration of Error, CaptureResults, and UrlResults jsps via getters and setters REFACTOR: moved code for forwarding requests to .jsps into a single method. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java 2007-07-19 20:39:07 UTC (rev 1810) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/query/Renderer.java 2007-07-19 20:41:26 UTC (rev 1811) @@ -49,35 +49,41 @@ * @version $Date$, $Revision$ */ public class Renderer implements QueryRenderer { - private final static String JSP_PATH = "queryui.jsppath"; - private String jspPath = null; - - private final String ERROR_JSP = "ErrorResult.jsp"; - - private final String QUERY_JSP = "QueryResults.jsp"; - - private final String PREFIX_QUERY_JSP = "PathQueryResults.jsp"; - + private String templateJsp = "/index.jsp"; + private String errorJsp = "/jsp/HTMLError.jsp"; + private String captureJsp = "/jsp/HTMLResults.jsp"; + private String urlJsp = "/jsp/HTMLResults.jsp"; + public void init(Properties p) throws ConfigurationException { PropertyConfiguration pc = new PropertyConfiguration(p); - jspPath = pc.getString(JSP_PATH); +// jspPath = pc.getString(JSP_PATH); } + /** + * @param request + * @param response + * @param jspName + * @throws ServletException + * @throws IOException + */ + private void proxyRequest(HttpServletRequest request, + HttpServletResponse response, final String jspPath) + throws ServletException, IOException { + + RequestDispatcher dispatcher = request.getRequestDispatcher(jspPath); + dispatcher.forward(request, response); + } + public void renderException(HttpServletRequest httpRequest, HttpServletResponse httpResponse, WaybackRequest wbRequest, WaybackException exception) throws ServletException, IOException { httpRequest.setAttribute("exception", exception); UIResults uiResults = new UIResults(wbRequest); - uiResults.storeInRequest(httpRequest); + uiResults.storeInRequest(httpRequest,errorJsp); - String finalJspPath = jspPath + "/" + ERROR_JSP; - - RequestDispatcher dispatcher = httpRequest - .getRequestDispatcher(finalJspPath); - - dispatcher.forward(httpRequest, httpResponse); + proxyRequest(httpRequest,httpResponse,errorJsp); } public void renderUrlResults(HttpServletRequest httpRequest, @@ -95,8 +101,8 @@ throw new ServletException(e.getMessage()); } - uiResults.storeInRequest(httpRequest); - proxyRequest(httpRequest, httpResponse, QUERY_JSP); + uiResults.storeInRequest(httpRequest,captureJsp); + proxyRequest(httpRequest, httpResponse, captureJsp); } @@ -118,26 +124,50 @@ throw new ServletException(e.getMessage()); } - uiResults.storeInRequest(httpRequest); - proxyRequest(httpRequest, httpResponse, PREFIX_QUERY_JSP); + uiResults.storeInRequest(httpRequest,urlJsp); + proxyRequest(httpRequest, httpResponse, urlJsp); } /** - * @param request - * @param response - * @param jspName - * @throws ServletException - * @throws IOException + * @return the errorJsp */ - private void proxyRequest(HttpServletRequest request, - HttpServletResponse response, final String jspName) - throws ServletException, IOException { + public String getErrorJsp() { + return errorJsp; + } - String finalJspPath = jspPath + "/" + jspName; + /** + * @param errorJsp the errorJsp to set + */ + public void setErrorJsp(String errorJsp) { + this.errorJsp = errorJsp; + } - RequestDispatcher dispatcher = request - .getRequestDispatcher(finalJspPath); - dispatcher.forward(request, response); + /** + * @return the captureJsp + */ + public String getCaptureJsp() { + return captureJsp; } + + /** + * @param captureJsp the captureJsp to set + */ + public void setCaptureJsp(String captureJsp) { + this.captureJsp = captureJsp; + } + + /** + * @return the urlJsp + */ + public String getUrlJsp() { + return urlJsp; + } + + /** + * @param urlJsp the urlJsp to set + */ + public void setUrlJsp(String urlJsp) { + this.urlJsp = urlJsp; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |