Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-tapestry Wiki" for change notification.
The following page has been changed by ManriOffermann: http://wiki.apache.org/jakarta-tapestry/PagesAndComponentsInWEB-INF New page: = How to have pages and components under a specific folder in WEB-INF = The following is an implementation of the ISpecificationResolverDelegate which searches page and component specifications in a given folder under WEB-INF. With this configuration you can reference pages and components without defining them in the application specification. It also enables you to store pages and components in subfolders, which can be useful if the number of files in your WEB-INF grows. The class: {{{ public class MySpecificationResolverDelegate implements ISpecificationResolverDelegate { private ISpecificationSource specificationSource; private String pagePath; private String componentPath; private boolean isInitialized; private boolean isCacheDisabled; private Resource pagesBaseLocation; private Resource componentsBaseLocation; private Map componentMap = new HashMap(); private Map pageMap = new HashMap(); /** * @param specificationSource The specificationSource to set. */ public void setSpecificationSource(ISpecificationSource specificationSource) { this.specificationSource = specificationSource; } /** * @param componentPath The componentPath to set. */ public void setComponentPath(String componentPath) { this.componentPath = componentPath; } /** * @param pagePath The pagePath to set. */ public void setPagePath(String pagePath) { this.pagePath = pagePath; } /** * @see org.apache.tapestry.resolver.ISpecificationResolverDelegate#findComponentSpecification(org.apache.tapestry.IRequestCycle, org.apache.tapestry.INamespace, java.lang.String) */ public IComponentSpecification findComponentSpecification(IRequestCycle cycle, INamespace namespace, String type) { if (!isInitialized) init(namespace); if (!isCacheDisabled && componentMap.containsKey(type)) return (IComponentSpecification) componentMap.get(type); if (namespace.isApplicationNamespace()) { Resource componentResource = componentsBaseLocation.getRelativeResource(type + ".jwc"); if (componentResource != null) { IComponentSpecification componentSpecification = specificationSource.getComponentSpecification(componentResource); if (!isCacheDisabled) componentMap.put(type, componentSpecification); return componentSpecification; } } return null; } /** * @see org.apache.tapestry.resolver.ISpecificationResolverDelegate#findPageSpecification(org.apache.tapestry.IRequestCycle, org.apache.tapestry.INamespace, java.lang.String) */ public IComponentSpecification findPageSpecification(IRequestCycle cycle, INamespace namespace, String simplePageName) { if (!isInitialized) init(namespace); if (!isCacheDisabled && pageMap.containsKey(simplePageName)) return (IComponentSpecification) pageMap.get(simplePageName); if (namespace.isApplicationNamespace()) { Resource pageResource = pagesBaseLocation.getRelativeResource(simplePageName + ".page"); if (pageResource != null) { IComponentSpecification componentSpecification = specificationSource.getPageSpecification(pageResource); if (!isCacheDisabled) pageMap.put(simplePageName, componentSpecification); return componentSpecification; } } return null; } private void init(INamespace namespace) { isCacheDisabled = "true".equals(System.getProperty("org.apache.tapestry.disable-caching")); while (!namespace.isApplicationNamespace()) namespace = namespace.getParentNamespace(); if (namespace.isApplicationNamespace()) { Resource namespaceLocation = namespace.getSpecificationLocation(); pagesBaseLocation = namespaceLocation.getRelativeResource(pagePath + "/"); componentsBaseLocation = namespaceLocation.getRelativeResource(componentPath + "/"); isInitialized = true; } } } }}} And here's the necessary hivemind.xml configuration. The values of 'pagePath' and 'componentPath' are the path to your pages and components folder under WEB-INF: {{{ <implementation service-id="tapestry.page.SpecificationResolverDelegate"> <invoke-factory> <construct class="foo.bar.MySpecificationResolverDelegate"> <set property="pagePath" value="pages"/> <set property="componentPath" value="components"/> <set-object property="specificationSource" value="infrastructure:specificationSource"/> </construct> </invoke-factory> </implementation> }}} Example: Now you can access the page stored under 'WEB-INF/pages/foo/Test.jwc' and 'WEB-INF/pages/foo/Test.html' by linking to the page as follows: {{{ <a jwcid="@PageLink" page="foo/Test" href="">test page</a> }}} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]