Author: musachy Date: Fri Jun 6 10:36:17 2008 New Revision: 664051 URL: http://svn.apache.org/viewvc?rev=664051&view=rev Log: Add new configuration setting to enable results to be in a subdir
Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java struts/sandbox/trunk/struts2-convention-plugin/src/main/resources/struts-plugin.xml Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java?rev=664051&r1=664050&r2=664051&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java (original) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java Fri Jun 6 10:36:17 2008 @@ -116,6 +116,7 @@ private final ServletContext servletContext; private Set<String> relativeResultTypes; private ConventionsService conventionsService; + private boolean flatResultLayout = true; /** * Constructs the SimpleResultMapBuilder using the given result location. @@ -134,6 +135,16 @@ } /** + * @param flatResultLayout If 'true' result resources will be expected to be in the form + * ${namespace}/${actionName}-${result}.${extension}, otherwise in the form + * ${namespace}/${actionName}/${result}.${extension} + */ + @Inject("struts.convention.result.flatLayout") + public void setFlatResultLayout(String flatResultLayout) { + this.flatResultLayout = "true".equals(flatResultLayout); + } + + /** * [EMAIL PROTECTED] */ public Map<String, ResultConfig> build(Class<?> actionClass, @@ -213,7 +224,7 @@ // Build from web application using the ServletContext @SuppressWarnings("unchecked") - Set<String> paths = servletContext.getResourcePaths(resultPath); + Set<String> paths = servletContext.getResourcePaths(flatResultLayout ? resultPath : resultPrefix); if (paths != null) { for (String path : paths) { if (LOG.isTraceEnabled()) { @@ -288,7 +299,7 @@ int indexOfDot = path.indexOf('.', resultPrefix.length()); // This case is when the path doesn't contain a result code - if (indexOfDot == resultPrefix.length()) { + if (indexOfDot == resultPrefix.length() || !flatResultLayout) { if (LOG.isTraceEnabled()) { LOG.trace("The result file [#0] has no result code and therefore" + " will be associated with success, input and error by default. This might" + Modified: struts/sandbox/trunk/struts2-convention-plugin/src/main/resources/struts-plugin.xml URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-convention-plugin/src/main/resources/struts-plugin.xml?rev=664051&r1=664050&r2=664051&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-convention-plugin/src/main/resources/struts-plugin.xml (original) +++ struts/sandbox/trunk/struts2-convention-plugin/src/main/resources/struts-plugin.xml Fri Jun 6 10:36:17 2008 @@ -38,6 +38,7 @@ <bean type="com.opensymphony.xwork2.config.PackageProvider" class="org.apache.struts2.convention.ClasspathConfigurationProvider"/> <constant name="struts.convention.result.path" value="/WEB-INF/content/"/> + <constant name="struts.convention.result.flatLayout" value="true"/> <constant name="struts.convention.action.suffix" value="Action"/> <constant name="struts.convention.action.disableScanning" value="false"/> <constant name="struts.convention.action.disableJarScanning" value="true"/>