This is all the default behavior in Tapestry 4. Page "foo/Bar" will be template foo/Bar.html, specification WEB-INF/foo/Bar.jwc and the default class will be [some package].foo.Bar.
On 9/9/05, Pete <[EMAIL PROTECTED]> wrote: > Hi! > > My intention was to put the page templates into subfolders. > > like that: > > /Home.html > /admin/Login.html > /shop/BrowseArticles.html > > > My solution works by evaluating the app-property > 'org.apache.tapestry.page-class-packages' which specifies the > location of your class files. the code will _not_ work for .page > specification files (even though this > behaviour could probably achieved as easy). > > example: > > [org.apache.tapestry.page-class-packages = de.mycompany.webapp.pages] > > url: http://myhost:port/context/admin/Login.html -> class: > de.mycompany.webapp.pages.admin.Login > url: http://myhost:port/context/admin/test/text/Foobar.html -> class: > de.mycompany.webapp.pages.admin.test.text.Fooba > > > It's simple and straightforward. I would like some feedback from you if I > am missing something. Especially I am not sure if > this solution is compatible with namespaces. If everything is fine I be > happy to donate that piece of code to the community. > > It probably can also be used for components. > > <span jwcid="@test/MyComponent"/> seems to work but looks somehow strange > *ugh* > > > > > [ hivemodule.xml ] > > <service-point id="NestedComponentClassLoader" > interface="org.apache.tapestry.pageload.ComponentClassProvider"> > <invoke-factory> > <construct class="NestedComponentClassLoader"> > <set-object property="packageRoot" > value="app-property:org.apache.tapestry.page-class-packages"/> > </construct> > </invoke-factory> > </service-point> > > <contribution configuration-id="tapestry.page.PageClassProviderChain"> > <command id="locateNestedPageClass" > object="service:NestedComponentClassLoader" /> > </contribution> > > > [ NestedComponentClassLoader.java ] > > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.apache.tapestry.pageload.ComponentClassProvider; > import org.apache.tapestry.pageload.ComponentClassProviderContext; > > public class NestedComponentClassLoader implements ComponentClassProvider > { > private static final Log log = > LogFactory.getLog(NestedComponentClassLoader.class); > > private String packageRoot; > > public void setPackageRoot(String packageRoot) > { > this.packageRoot = packageRoot; > } > > public String provideComponentClassName(ComponentClassProviderContext > context) > { > String name = context.getName(); > > int slashPos = name.lastIndexOf('/'); > > if (slashPos == -1 || slashPos == name.length()) > return null; > > String path = name.substring(0, slashPos); > String page = name.substring(slashPos + 1); > > StringBuilder classpath = new StringBuilder(packageRoot); > > for (String pathComponent : path.split("/")) > { > classpath.append('.'); > classpath.append(pathComponent); > } > classpath.append('.'); > classpath.append(page); > > log.debug(String.format("page '%s' -> class '%s'", page, > classpath.toString())); > > return classpath.toString(); > } > } > > > Best regards > Peter > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Howard M. Lewis Ship Independent J2EE / Open-Source Java Consultant Creator, Jakarta Tapestry Creator, Jakarta HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
