File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes General Tiles Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "General Tiles Questions" Watch "General Tiles Questions" New topic
Author

General Tiles Questions

Brian M Smith
Ranch Hand

Joined: Aug 13, 2009
Posts: 35
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!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 13, 2009
Posts: 35
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 13, 2009
Posts: 35
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sounds like you want SiteMesh, not Tiles.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: General Tiles Questions