I've been think about Howard's email a couple of days ago and it occurred to me that while Tapestry provides a very good set of tools for solving common problems encountered doing web development it does not actually solve them. This is not a complaint and in fact I think it's the right approach for a framework, but I think in order to build a community around Tapestry these common problems need a common solution. The great thing about Tapestry and IOC is you can build a common solution and then either replace or extend it.
During this same time I noticed a couple of email about how to implement defaults. Tapestry provides a way to do this buy it's completely static. That's a good start but it does not really solve the application development problem. Problem Definition: There needs to be a way to have defaults for various values used by an application. Defaults should be provided by modules. It should be possible to override these defaults via the Tapestry IOC applications default mechanism. And finally it should be possible to override this defaults and runtime. The runtime mechanism may be provided by the application so defaults could for example be stored in a database. Lastly the override mechanism should allow overriding the defaults based on the context. While this sounds like a pretty tall order thanks to the tools provided by Tapestry it's actually pretty easy. The Solution: There are a few parts to the solution. 1. Implement a binding prefix called default which can retrieve the default for a key 2. Provide a way to contribute module defaults 3. Provide a service that can retrieve defaults for a binding key Creating a binding prefix is easy: https://github.com/trsvax/tapestry-trsvax/blob/master/src/main/java/com/trsvax/tapestry/misc/services/DefaultBinding.java Contributing binding defaults is even easier: public final static String id = "MiscModule"; @Contribute(Defaults.class) public static void contributeDefautls(MappedConfiguration<String, StaticDefaults> configuration) { configuration.add(id,new MyDefaults()); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
