Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Tiles Inheritance problem

 
Todd Nine
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic