Joshua Jackson wrote:
Dear all,

By default T4 files such as *.jwc, *.page, *.html are required to be
place inside WEB-INF/.

But I find this quite messy when there are other configuration from
another framework. Is there any way I can move these files to another
folder?

Thanks in advance

Hi Joshua,

Tapestry's HiveMind configuration provides two service points that can be implemented: tapestry.page.SpecificationResolverDelegate (to find page/component specifications), and tapestry.parse.TemplateSourceDelegate (to find page/component templates). Implementations of ISpecificationResolverDelegate and ITemplateSourceDelegate, respectively, can be plugged into these service-points.

So I created a drop-in JAR with:
 1.  My own implementation of ISpecificationResolverDelegate
 2.  My own implementation of ITemplateSourceDelegate
3. META-INF/hivemodule.xml to tell HiveMind how to plug those implementations into Tapestry's configuration.


Here's my slightly-censored hivemodule.xml:

<module id="com.company...ModuleName"
   version="1.0.0" package="com.company...">
 <implementation service-id="tapestry.page.SpecificationResolverDelegate">
   <invoke-factory>
     <construct class="SpecificationResolverDelegate">
<set-object property="context" value="service:tapestry.globals.WebContext" />
     </construct>
   </invoke-factory>
 </implementation>

 <implementation service-id="tapestry.parse.TemplateSourceDelegate">
   <invoke-factory>
     <construct class="com.company...TemplateSourceDelegate">
<set-object property="context" value="service:tapestry.globals.WebContext" /> <set-object property="parser" value="service:tapestry.parse.TemplateParser" /> <set-object property="resolver" value="service:tapestry.page.ComponentSpecificationResolver" />
     </construct>
   </invoke-factory>
 </implementation>
</module>


As for the implementations, I just used modified copies of Tapestry's default implementations. I inject the WebContext not just so I can create filepaths relative from the deployed application, but also so I can specify the paths for my templates/specifications via init-parameters in my web.xml, making the module useful in multiple web applications. You can also create default specifications on the fly if a specification file isn't found; by requiring specific conventions, you can code your implementations in such a way that *.jwc and *.page files need not exist. The implementations that ship with Tapestry should give you a pretty good idea as to how you can work in your own behavior.

Jim



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to