Tiles is a great framework to organize site content by constructing a page using multiple tiles. It allows reuse and customization of site content. I ran into a problem of making tiles attribute visible to a nested tile. The attributes defined in tiles definitions are defined in tiles scope and hence only available to the tile associated with the definition. In order to make the attribute available to nested tiles, pass the attribute as follows;
<tiles:insert attribute="header" ignore="true">
<tiles:put name="title" beanName="title" beanScope="tile"/>
</tiles:insert>
If there is a need to access the attribute in struts bean tags or JSTL use <tiles:useAttribute/> or <tiles:importAttribute/> tags in jsp to access the attribute as follows;
<tiles:useAttribute name="title" />
You can now access the value of title attribute using struts bean tag <bean:write name="title" /> or using JSTL as ${title}
For more detailed explanation look at a sample chapter Developing applications with tiles from the book Struts in Action.
More advanced tips and tricks for tiles can be found in Master the Tiles framework and The Advanced Fratures.
<tiles:insert attribute="header" ignore="true">
<tiles:put name="title" beanName="title" beanScope="tile"/>
</tiles:insert>
If there is a need to access the attribute in struts bean tags or JSTL use <tiles:useAttribute/> or <tiles:importAttribute/> tags in jsp to access the attribute as follows;
<tiles:useAttribute name="title" />
You can now access the value of title attribute using struts bean tag <bean:write name="title" /> or using JSTL as ${title}
For more detailed explanation look at a sample chapter Developing applications with tiles from the book Struts in Action.
More advanced tips and tricks for tiles can be found in Master the Tiles framework and The Advanced Fratures.
Comments