|
|
|
Tiles
Large web sites often need a common Look and Feel (L&F). If the L&F is hard coded in all pages, changing it becomes a nightmare: you would have to modify nearly all pages. In a good design, we want to separate the L&F and page content. Using a template allows to define a master L&F: position of header, menu body, content, and footer. The page content is defined in a JSP page without worrying about the L&F. The final page is built by passing header, menu, body and footer to the template which in turn builds them as requested. Header, menu and footer can be the same for all final pages. In addition using a stylesheet allows a consistent policy of formats and colors. Another aspect to web development is often redoing the same things: websites contain many common parts: menus, forms, shopping cart, etc… Each time we have to rewrite or copy & paste the same code. But what happens when you improve the code, or when you discover a bug? You need to modify all your copy & pasted sections ! A solution is to have reusable components that you insert where you need them. You always insert the same components, but with different data. Now, if you modify the component, the modification is spread everywhere you use it is used: you have a central point for modification. Tiles allow both templating and componentization. In fact, both mechanisms are similar: you define parts of page (a “Tile”) that you assemble to build another part or a full page. A part can take parameters, allowing dynamic content, and can be seen as a method in JAVA language. A template and a layout are both the same: they describe where parts should be laid out in a bigger part, or in a final page. Both terms are use interchangeably in this document. Layout = a description of where Tiles should be laid Template = a complete HTML page with "html", "head" and "body" tags and a layout Layouts, or Templates, are described in a JSP page by using available tags. In your layout description, you place special tags where you want to render a Tile. To build a layout, you need to know where you want to go. First, draw a layout example on a paper and identify parts or Tiles you want to be rendered. Name each Tile with a generic name, like header, menu, body, footer, or up, down, center, left and right.
|
|