From 3fcfcad103d325fff8b77652bbc2724ff6d2e32e Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Thu, 4 Jan 2007 22:43:10 +0000 Subject: [PATCH] Added ability to customize template path prefix WW-1595 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@492788 13f79535-47bb-0310-9956-ffa450edef68 --- .../struts2/codebehind/CodebehindUnknownHandler.java | 9 +++++++-- plugins/codebehind/src/main/resources/struts-plugin.xml | 5 ++++- .../struts2/codebehind/CodebehindUnknownHandlerTest.java | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java b/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java index ad2a75b1d..a6242202d 100644 --- a/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java +++ b/plugins/codebehind/src/main/java/org/apache/struts2/codebehind/CodebehindUnknownHandler.java @@ -53,15 +53,20 @@ import com.opensymphony.xwork2.inject.Inject; */ public class CodebehindUnknownHandler implements UnknownHandler { - protected String defaultPackageName = "codebehind-default"; + protected String defaultPackageName; protected ServletContext servletContext; protected Map resultsByExtension; - protected String templatePathPrefix = "/"; + protected String templatePathPrefix; protected Configuration configuration; protected ObjectFactory objectFactory; protected static final Log LOG = LogFactory.getLog(CodebehindUnknownHandler.class); + @Inject("struts.codebehind.pathPrefix") + public void setPathPrefix(String prefix) { + this.templatePathPrefix=prefix; + } + @Inject("struts.codebehind.defaultPackage") public void setDefaultPackage(String pkg) { this.defaultPackageName = pkg; diff --git a/plugins/codebehind/src/main/resources/struts-plugin.xml b/plugins/codebehind/src/main/resources/struts-plugin.xml index 1bc6de17f..1b8a7a72b 100644 --- a/plugins/codebehind/src/main/resources/struts-plugin.xml +++ b/plugins/codebehind/src/main/resources/struts-plugin.xml @@ -6,7 +6,10 @@ - + + + + diff --git a/plugins/codebehind/src/test/java/org/apache/struts2/codebehind/CodebehindUnknownHandlerTest.java b/plugins/codebehind/src/test/java/org/apache/struts2/codebehind/CodebehindUnknownHandlerTest.java index 0bf246b1a..49e3ca2ea 100644 --- a/plugins/codebehind/src/test/java/org/apache/struts2/codebehind/CodebehindUnknownHandlerTest.java +++ b/plugins/codebehind/src/test/java/org/apache/struts2/codebehind/CodebehindUnknownHandlerTest.java @@ -44,10 +44,11 @@ public class CodebehindUnknownHandlerTest extends StrutsTestCase { super.setUp(); mockServletContext = new Mock(ServletContext.class); handler = new CodebehindUnknownHandler(); + handler.setDefaultPackage("codebehind-default"); + handler.setPathPrefix("/"); handler.setConfiguration(configuration); handler.setObjectFactory(container.getInstance(ObjectFactory.class)); handler.setServletContext((ServletContext)mockServletContext.proxy()); - } public void testBuildResult() {