Patchwork

Patchwork is an extension to the Apache Cocoon framework which gives you the possibility to define and inherit layouts. This is similar to the Struts plugin Tiles, but adjusted to the requirements for using such a technique within Apache Cocoon.

The term layout definition or in short layout in Patchwork is defined by the following items:

  • Each layout represents a single HTML template file.
  • Each layout can include several other layouts. This is called an include.
  • Each web page has exactly one master layout. This layout cannot be included into other layouts.
  • A layout describes the path to a template file.
  • A layout can have properties associated to it.
  • A layout can contain content definintions or refer to such.
  • The settings of a layout such as includes, template path, properties and content definitions can be inherited by another layout.

Features of patchwork

Centralized layout configuration

Patchwork allows you to define the structure of your layouts in one central place. Therefore if you wan't to create a new layout or if you configure existing layouts you can do it within one single xml document. This makes it much more easier for you to get an overview of the websites layout structure and to introduce new layouts.

Avoids additional Controller logic

Depending on the layout you would like to load, Patchwork merges them together for you, without the need of writing any Controller and merge logic. And sure, there is nothing that speaks against adding additional Controllers if you want to do so!

Layout inheritance

Once you have created your additional layout structure you can inherit from other layouts as well. Doing it this way allows you to avoid redundancy and makes your work much more faster and productively!

Caching

Using the PatchworkGenerator, Patchwork can cache all merged layouts. This can improve the performance drastically! (Currently not implemented, but in the pipeline.)