It's not a secret anymore!
The moose likes Struts and the fly likes tile question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "tile question" Watch "tile question" New topic

tile question

Hong Yi

Joined: Feb 13, 2008
Posts: 11
How do I add action to a common element (header.jsp) for tile layout?

Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Hi Hong Yi,

If I understand your question, you want to use header.jsp in several tiles?.?.

That being the case, you can extend a tile from a parent. Example:

Suppose you have an action mapping in your struts-config.xml to display your home page, which you want to incorporate header.jsp

In your tiles-defs.xml, do the following:

In this case, tile:showhome inherits tile:layout which contains header.jsp.

Now, in layout.jsp, do something like this:

Now, you can reuse layout by extending it in other tiles and changing the page.body name attribute to whatever jsp applies for the other pages.

I hope that answers your question...

-- Nothing is impossible if I'mPossible
I agree. Here's the link:
subject: tile question
It's not a secret anymore!