1. Tapestry 5, Spring, Hibernate and Transaction

    A new project has been added at spreadthesource, it allows you to make Tapestry 5 services and Spring beans work in the same transaction. This contribution overrides the services provided by tapestry5-hibernate contribution to wrap the beans provided by spring. Also, It creates all the elements needed by Spring to work in a transaction.

    This contribution will be useful if :

    1. You want to benefit from an existing spring configuration to start writing data access code in Tapestry 5 services
    2. You have a mixed architecture (Tapestry 5 and Spring) and you have to work in the same transaction context
    3. You want to migrate from your existing spring bean to Tapestry and then benefit from the great hot reload feature

    In our case, for wooki we have used spring acl that uses a JDBCTemplate to query the database, our business layer has moved to Tapestry 5 for the hot reload feature, so we needed to find a solution to create ACLs in the same transaction than the main business method.

    The project is available on github, and you can find more information in the README and test application provided with this contribution.

  2. Decorating RenderSupport and any MarkupRendererFilter

    I recently faced to some limitations with RenderSupport. I wanted to decorate it but I realized that this filter is not a service. What a shame, one of the most important Tapestry 5 service is not customisable…

    Really? No. There is a possibility to decorate RenderSupport, and in fact any of MarkupRendererFilter and Environment objects.

    How to achieve that?

    • Create a new RenderSupport implementation that will wrap the initial object. It’s just like we normally do when creating a decorator.
    • Create a MarkupRendererFilter that will pop RenderSupport from Environment
    • Create a the interceptor from the poped RenderSupport and push it into the Environment.
    • Contribute to MarkupRenderer’s ordered configuration and add your filter just after RenderSupport.
        public void contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter> configuration)    {
            MarkupRendererFilter renderSupportInterceptor = new MarkupRendererFilter()
            {
                public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer)
                {
                    RenderSupport delegate = (RenderSupport) environment.pop(RenderSupport.class);
                    RenderSupport interceptor = new RenderSupportInterceptor(delegate);
    
                    environment.push(RenderSupport.class, interceptor);
                    renderer.renderMarkup(writer);
                }
            };
            configuration.add("RenderSupportDecorator", renderSupportInterceptor, "after:RenderSupport", "before:ClientBehaviorSupport",
                    "before:InjectDefaultStyleheet", "before:Heartbeat");
        }
    
  3. Atom and RSS feeds for Tapestry 5

    Another contribution this week for Tapestry 5 after the awesome “tapestry5-installer” : an integration of the Rome library. Rome is kind of a Java standard for generating Atom and RSS feeds.

    Rome gives you all you need to produce feeds. The only thing that may be tricky for newcomers to Tapestry 5 then is not how to produce them but how to return them. This is what “tapestry5-rome” contribution is doing: offering the possibility for action methods to return feeds.

    Want to see a sample? Check out the test page source code. Install instructions can be found in the readme file.

    Don’t forget to follow “spreadthesource” on Github to stay informed for any contributions updates.

  4. Create your web installation wizard for your Tapestry 5 applications

    For wooki, we needed to find an easy way for the user to install wooki and set its production environment properties like database URL or file upload directory. Main objectives are :

    1. No manual server restart after application configuration
    2. Easy to install : put the wooki.war in the ‘webapps’ folder, go to the browser, configure and that’s all
    3. Develop the installation application with Tapestry, no way to use JSP ;)
    4. Package the installation application with wooki.war
    5. Allow spring to directly access to the properties set by the user
    6. Run the installation application with a minimal set of Tapestry Modules to avoid hibernate or spring to load early on startup

    Then we have developed this solution in a standalone contribution that you can find on github with full documentation. It has been build with tapestry 5.2.0 because wooki now uses this version of Tapestry (but really requires less effort to move to 5.1.0.5)

    The solution has been tested with the current working branch of wooki and we expect to make it evolve to provide facilities for hibernate configuration for exemple. By the way, give it try if you are interested in and do not hesitate to post your comments/suggestions.