wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts Tiles Inheritance problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Tiles Inheritance problem" Watch "Struts Tiles Inheritance problem" New topic
Author

Struts Tiles Inheritance problem

Todd Nine
Greenhorn

Joined: Oct 28, 2004
Posts: 5
I'm having issues with inheritance using tiles. I have a main page layout containing 4 tiles:
header
footer
menu
body


This works fine, the problem comes when I try to insert tiles in the jsp that is the body portion of my page. I have 3 reusable tiles:

listusers.jsp
listroles.jsp
listgroups.jsp

I insert the listroles.jsp and the listgroups.jsp tiles in my profile.jsp page. The profile.jsp is the body tile of the main.layout tile. When I attempt to do this I get the following error.



When I debug struts, I notice that when is called, the current context contains null attributes. Given this I feel that it is a scope issue, since the profile.jsp is within a given layout. However, I don't know how to fix this, can anyone give me a hand? Below is my tiles.xml file, and my mainlayout.jsp, and profile.jsp. Thanks!

tiles.xml


mainLayout.jsp



profile.jsp

Todd Nine
Greenhorn

Joined: Oct 28, 2004
Posts: 5
Does anyone out there have any ideas? I'm getting very frustrated, I'm sure this is quite simple, but the documentation is nill on this setup. It only supports tiles 1 level deep from the root tile, surely this can recurse on a tree to a descendant of a tile, or can it only recurse to the child?

Thanks,
Todd
Herman Gomez
Greenhorn

Joined: Dec 15, 2004
Posts: 4
Hi, I'm new with Tiles too, but I think I can help you.

You are trying to use tiles in a tile file. That's not the idea. The tiles must be inserted into layouts. The layout is the model, with some holes where you put the tiles.

In your layout you can use <tiles:get...> to get the content of a tile. But you can't use that tag to insert content into another tile (profile.jsp). This means that tiles must be independent of each other.

The only ones that depends on them are the layouts. You cannot have a layout into another layout. Remember it.

If there is a tile that you don't want to use in a layout, you can set that property to blank and configure it to not show an error with something like this:

In the definition:
<put name="extra.component" value=""/>

In the layout:
<tiles:insert attribute="extra.component" ignore="true" />

And the error doesn't show up.

Regards,
Herman.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts Tiles Inheritance problem
 
Similar Threads
Problem with struts tiles
Access resources from jsp without using "bean:message" tag
confusion on struts tile
Interesting tiles/struts making a menu question
Tiles in struts?