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
This commit is contained in:
Donald J. Brown
2007-01-04 22:43:10 +00:00
parent 8fa10b63d8
commit 3fcfcad103
3 changed files with 13 additions and 4 deletions
@@ -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<String,ResultTypeConfig> 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;
@@ -6,7 +6,10 @@
<struts>
<bean type="com.opensymphony.xwork2.UnknownHandler" class="org.apache.struts2.codebehind.CodebehindUnknownHandler" />
<constant name="struts.codebehind.pathPrefix" value="/"/>
<constant name="struts.codebehind.defaultPackage" value="codebehind-default"/>
<package name="codebehind-default" extends="struts-default">
</package>
</struts>
@@ -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() {