2

I'm new to the Struts 2 world. I just figured out how to use the Convention plugin and I must say it's quite nice.

However, all of my JSP files of course have the complete head, title, etc. I want to build a reusable template and plug in various views (much like how Rails does it with the application.html.erb)

I got Tiles to work on a Struts 1 site before and it was a total nightmare. In my Struts 2 app, I am using the convention pattern so I have had almost no XML and would like to keep it that way.

Is there an easier way to do this other than Tiles?

Thanks.

cbmeeks
  • 11,248
  • 22
  • 85
  • 136
  • I don't know much about the history of tiles but tiles has progressed as well (Many would say working with Struts1 was hell too, at least compared to what we have now). I would recommend checking out it's wild card feature, there are annotations now (although I've stuck with xml). So I'd recommend giving it another shot since you have a bit of experience with the old you'll probably get up to speed more quickly, but the main competitor to tiles2 as far as I know is Sitemesh. So look into both. – Quaternion Apr 02 '11 at 17:36

1 Answers1

0

Yes. Use the JSP 2.0 tag file feature. My answer to a previous, similar question may be of some use to you.

JSP, can it work similar to yield, layout, content_for in Ruby/Rails/Erb

Community
  • 1
  • 1
Steven Benitez
  • 10,936
  • 3
  • 39
  • 50
  • 1
    The power of tiles2 for me comes from it's inheritance feature (you create a master template and then override sections of it). Also it has wild card features which can be used to reduce the configuration (like struts xml wild cards). I think for over all layout tiles or sitemesh make the most sense they work at a higher level then the JSP 2.0 tags but the tags are the right way to go for components. – Quaternion Apr 02 '11 at 17:22
  • Perhaps. I've always found Tiles to be clunky and I've used the tag file approach for years now with great success. To each his own, I suppose. – Steven Benitez Apr 02 '11 at 18:06
  • Agreed , but the initial configuration aspect is quite a hell :'( – Gayan Hewa Mar 26 '12 at 06:34