Saturday, July 24, 2010

What does Tiles do?

Tiles helps us to create consistent layouts through out the product/website. For example, consider the scenerio of having one header.jsp/footer.jsp and multiple content.jsp.

Here content.jsp could be changing for each and every request. In simple jsp implementation, we can achieve this by passing content jsp name as request attribute from the action class and dynamically we can include the jsp through jsp scriptlet (<%=request.getAttribute("contentName")%> or through some jstl core tags like c:get.

Now what we need to do if we have multiple header.jsp and footer.jsp. In other words what we will do if we need to show customer specific headers and footers but at the same time we need to maintain consistent L & F through out the product/website. Here comes the real usage of tiles, we will have only one layout.jsp and we will insert different header jsps (say header1.jsp header2.jsp etc) through tiles-def.xml combined with struts forwarding mechanism.

So basically tiles helps us to abstract and decouple layout and implementation jsps.

No comments:

Post a Comment