How to reuse Tiles definitions using wildcard


If you are developing project in java/j2ee and using Tiles then you are aware of Tiles definition XML file. Being Templating framework, Tiles used one definition per view to render output. User can extend this definition with a defined template so all the common pages will be rendered by the template but still you need one definition per jsp.

Consider a scenario where you have three user roles (admin, manager, and employee) and for each you have created a separate jsp. With this requirement you might end up with such tiles definitions.

Tiles v2.2 comes with the wildcard character support in definitions name. With the above scenario, we can make these three definitions into one using wildcard.

Spring configuration xml file

I have used Spring MVC to integrate Tiles and used Spring view controller to avoid creating java Controller.

Output:

Download Source (size: 60 Kb)

Download WAR (size: 4.61 Mb)

About the Author

has written 69 posts.

I Love Coding, Analyzing, Designing and doing it the right way. I am obsessed about learn anything new daily and sharing what I have learn each Day. This Blog is journey of my Zeal, going through step by step to the mountain of desire to become prefect. Google Wanna Hire me ?

Copyright © 2019 http://www.techzoo.org. All rights reserved.
Proudly powered by WordPress. Developed by 7Tech Solutions