• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

General Tiles Questions

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working with an app that is running on a fairly old JRE, and thus using an older version of struts and tiles. I'm using Tiles 1.

I have been looking around at various tiles examples, but a few things are eluding me. I'm not quite sure how definitions are used and how to invoke them. I'm also confused on how I can make a template work without having to create 2 JSP pages for 1 web facing page. What I mean by this is that I'm under the impression that I will have to make a extended definition and 2 JSP pages for each new page I create. That seems very inefficient. Is there a way that I could use a filter to automatically apply my template to outgoing responses?

I appreciate the help!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure why you'd need to create two JSPs for every page: one of the goals of Tiles is to allow for a generic, often application-wide template that includes an action-specific JSP. Are you using XML or JSP configuration?

Maybe if you posted some of your configuration you're not sure about it'd be easier to help--it's not clear to me what issue you're having with definitions, either.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:I'm not sure why you'd need to create two JSPs for every page: one of the goals of Tiles is to allow for a generic, often application-wide template that includes an action-specific JSP. Are you using XML or JSP configuration?

Maybe if you posted some of your configuration you're not sure about it'd be easier to help--it's not clear to me what issue you're having with definitions, either.



David,

Thank you for the response. I'm a real newbie when it comes to tiles. I guess I'm confused how tiles works in general. I have looked at various examples on various sites, and from what I gathered you had to have 2 JSP pages to make this work.

Here is my problem. I want to have one layout that is added to all the pages on my site. I want to use Struts to fill in the body content area of my layout, but I'm not sure how to do this with Tiles. I don't understand how I can make my web application automatically invoke a template(tile definition in a XML file) after a struts action executes logic and renders a body content page.

I really don't want to post code because I know that it's already wrong. I would much rather find some examples to look at. I hope this makes more sense.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using XML definitions you'd normally define a template (a tile definition). Then each page would extend that definition, adding action-specific contents--so there's a definition-per-action (or result), each extending a parent tile, including a specific JSP.

In Struts 1 you just use whatever the Tiles plugin is called. Instead of using a JSP in your action definitions you just use a tile definition name. In general a project will have a Tiles naming convention so it's obvious that the value used as the view is a Tile definition.

Maybe this (very) mini-tutorial will be enough to give you some ideas.
 
Brian M Smith
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

So if I'm understanding this correctly, for every customer facing JSP on my site I would have an extended entry in my tiles-def.xml file?

If that is the case, is it possible to bypass all of that and just include the template (header, left nav, footer) without having to make an entry for every JSP? My first thought was to use a filter and just take whatever the response is and wrap a template around it.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you want SiteMesh, not Tiles.
reply
    Bookmark Topic Watch Topic
  • New Topic