You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/09/01 21:01:30 UTC
svn commit: r1164204 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/services/templates/
main/java/org/apache/tapestry5/services/ test/appfolder/
test/appfolder/WEB-INF/ test/appfolder/images/ test/appfolder/t5...
Author: hlship
Date: Thu Sep 1 19:01:29 2011
New Revision: 1164204
URL: http://svn.apache.org/viewvc?rev=1164204&view=rev
Log:
TAP5-743: Allow for page templates in the folder, under the context
Begin adding tests
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/WEB-INF/
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/WEB-INF/web.xml
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/images/
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/images/t5-logo.png
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/t5app/
tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/t5app/ContextTemplate.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/ContextTemplate.java
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/Index.groovy
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/services/
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/services/AppModule.groovy
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/pages/
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/pages/Index.tml
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/templates/PageTemplateLocator.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/templates/PageTemplateLocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/templates/PageTemplateLocator.java?rev=1164204&r1=1164203&r2=1164204&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/templates/PageTemplateLocator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/templates/PageTemplateLocator.java Thu Sep 1 19:01:29 2011
@@ -14,8 +14,6 @@
package org.apache.tapestry5.internal.services.templates;
-import java.util.Locale;
-
import org.apache.tapestry5.TapestryConstants;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
@@ -23,9 +21,11 @@ import org.apache.tapestry5.model.Compon
import org.apache.tapestry5.services.ComponentClassResolver;
import org.apache.tapestry5.services.templates.ComponentTemplateLocator;
+import java.util.Locale;
+
/**
* The special case for pages, where the template is searched for in the web application context.
- *
+ *
* @since 5.2.0
*/
public class PageTemplateLocator implements ComponentTemplateLocator
@@ -34,15 +34,22 @@ public class PageTemplateLocator impleme
private final ComponentClassResolver resolver;
- public PageTemplateLocator(Resource contextRoot, ComponentClassResolver resolver)
+ private final String prefix;
+
+ public PageTemplateLocator(Resource contextRoot, ComponentClassResolver resolver, String applicationFolder)
{
this.contextRoot = contextRoot;
this.resolver = resolver;
+
+ prefix = applicationFolder.equals("") ? "" : applicationFolder + "/";
}
public Resource locateTemplate(ComponentModel model, Locale locale)
{
- if (!model.isPage()) { return null; }
+ if (!model.isPage())
+ {
+ return null;
+ }
String className = model.getComponentClassName();
@@ -60,7 +67,7 @@ public class PageTemplateLocator impleme
logicalName = logicalName.substring(0, slashx + 1) + simpleClassName;
}
- String path = String.format("%s.%s", logicalName, TapestryConstants.TEMPLATE_EXTENSION);
+ String path = prefix + logicalName + "." + TapestryConstants.TEMPLATE_EXTENSION;
return contextRoot.forFile(path).forLocale(locale);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1164204&r1=1164203&r2=1164204&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Thu Sep 1 19:01:29 2011
@@ -2809,12 +2809,14 @@ public final class TapestryModule
*/
public static void contributeComponentTemplateLocator(OrderedConfiguration<ComponentTemplateLocator> configuration,
@ContextProvider
- AssetFactory contextAssetFactory, ComponentClassResolver componentClassResolver)
+ AssetFactory contextAssetFactory,
+ @Symbol(SymbolConstants.APPLICATION_FOLDER) String applicationFolder,
+ ComponentClassResolver componentClassResolver)
{
configuration.add("Default", new DefaultTemplateLocator());
configuration
- .add("Page", new PageTemplateLocator(contextAssetFactory.getRootResource(), componentClassResolver),
- "after:Default");
+ .add("Page", new PageTemplateLocator(contextAssetFactory.getRootResource(), componentClassResolver, applicationFolder));
+
}
/**
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/WEB-INF/web.xml?rev=1164204&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/WEB-INF/web.xml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/WEB-INF/web.xml Thu Sep 1 19:01:29 2011
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <display-name>TAP5-74 Integration Test App</display-name>
+ <context-param>
+ <param-name>tapestry.app-package</param-name>
+ <param-value>org.apache.tapestry5.integration.appfolder</param-value>
+ </context-param>
+ <filter>
+ <filter-name>app</filter-name>
+ <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>app</filter-name>
+ <url-pattern>/t5app/*</url-pattern>
+ </filter-mapping>
+</web-app>
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/images/t5-logo.png
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/images/t5-logo.png?rev=1164204&view=auto
==============================================================================
Files tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/images/t5-logo.png (added) and tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/images/t5-logo.png Thu Sep 1 19:01:29 2011 differ
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/t5app/ContextTemplate.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/t5app/ContextTemplate.tml?rev=1164204&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/t5app/ContextTemplate.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/appfolder/t5app/ContextTemplate.tml Thu Sep 1 19:01:29 2011
@@ -0,0 +1,9 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
+
+<h1>Context Template Demo</h1>
+
+<img src="${context:images/t5-logo.png}" alt="Logo"/>
+
+<t:pagelink page="index">back to index</t:pagelink>
+
+</html>
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/ContextTemplate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/ContextTemplate.java?rev=1164204&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/ContextTemplate.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/ContextTemplate.java Thu Sep 1 19:01:29 2011
@@ -0,0 +1,8 @@
+package org.apache.tapestry5.integration.appfolder.pages;
+
+/**
+ *
+ */
+public class ContextTemplate
+{
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/Index.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/Index.groovy?rev=1164204&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/Index.groovy (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/pages/Index.groovy Thu Sep 1 19:01:29 2011
@@ -0,0 +1,7 @@
+package org.apache.tapestry5.integration.appfolder.pages
+
+/**
+ *
+ */
+class Index {
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/services/AppModule.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/services/AppModule.groovy?rev=1164204&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/services/AppModule.groovy (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/appfolder/services/AppModule.groovy Thu Sep 1 19:01:29 2011
@@ -0,0 +1,19 @@
+package org.apache.tapestry5.integration.appfolder.services
+
+import org.apache.tapestry5.SymbolConstants
+import org.apache.tapestry5.ioc.MappedConfiguration
+import org.apache.tapestry5.ioc.annotations.Contribute
+import org.apache.tapestry5.ioc.services.ApplicationDefaults
+import org.apache.tapestry5.ioc.services.SymbolProvider
+
+class AppModule
+{
+
+ @Contribute(SymbolProvider.class)
+ @ApplicationDefaults
+ static void applicationDefaults(MappedConfiguration<String, Object> configuration)
+ {
+ configuration.add(SymbolConstants.PRODUCTION_MODE, false)
+ configuration.add(SymbolConstants.APPLICATION_FOLDER, "t5app")
+ }
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/pages/Index.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/pages/Index.tml?rev=1164204&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/pages/Index.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/appfolder/pages/Index.tml Thu Sep 1 19:01:29 2011
@@ -0,0 +1,9 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
+
+<h1>App Folder Demo Application</h1>
+
+<img src="${context:images/t5-logo.png}" alt="Logo"/>
+
+<t:pagelink page="contexttemplate">context template demo</t:pagelink>
+
+</html>