If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Thursday, June 4, 2009

cocoon 2.2 block handling all file reading

I've seen many cocoon apps where they use properties in the sitemap to for instance dynamically construct the "src" attribute of a generator or reader. I also did not want to pollute my sitemap with multilevel selectors to get the job done. Well, there are more elegant ways to accomplish this. I used a combination of
  • the cocoon spring configurator
  • sitemap
  • flowscript
  • springbean
Screenshots below should make clear how i setup a (shared) block for ally upcoming publications to handle file reading.

Configure a bean with all knowledge about the repository containing images, xml, ...

Bean configuration:
















Java Bean snippet:


















Sitemap snippet:

























Flowscript snippet:
(which calls my javabean)



















So what basically happens is that the sitemap delegates the construction of the src attribute to a flowscript function. This flowscript call's my javabean based on the parameters it receives from the sitemap. Then another pipeline is invoked which
- generates the xml file in case of calling the xml pipeline
OR
- reads the file from disk

Cheers,
Robby Pelssers

No comments:

Post a Comment