Use a Tile Layout


In the previous section we created a layout is common for both dog.jsp and cat.jsp , In this section we will see how we can use that layout for both dog.jsp and cat.jsp.

First sep is to Import the tiles taglib with the taglib directive.
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

Second step is to Use tiles:insert to insert the tile layout into the current page.

<tiles:insert page="/layout.jsp" flush="true">
<tiles:put name="title" type="string" value="DOG" />
<tiles:put name="header" value="/header.jsp" />
<tiles:put name="footer" value="/footer.jsp" />
<tiles:put name="content" value="/dogContent.jsp"/>
</tiles:insert>

Third step is to Use tiles:put to pass string parameters.

<tiles:put name="title" type="string" value="Dog" />

Notice how tiles:put passes string parameters to the tile layout. The tiles:put's name attribute tag specifies the parameter name. The tiles:put's type attribute specifies the parameter's type. Lastly, the value parameter is passed the title attribute's value. That lets you pass simple strings as parameters when the tile layout (display function) gets called with the tiles:insert tag. The parameters become tile
layout attributes; that is, they get inserted into the tile scope of the tile layout.

Fourth step is to Use tiles:put to pass in parameter tiles.

<tiles:put name="header" value="/header.jsp" />
<tiles:put name="footer" value="/footer.jsp" />
<tiles:put name="content" value="/dogContent.jsp"/>

 


Tiles tutorial
Introduction to Tiles
Web Page Layouts
JSP pages with embedded HTML
JSP pages with JSP include directive's (static) or JSP actions (dynamic)
JSP templates
Tiles
Layouts
Classic layout
Menu layout
Vertical box or vbox or vstack layout layout
Multi-columns layout
Center layout
Tabs layout
Installing Tiles
For Struts1.0
For Struts1.1
For Tiles stand alone
Configuring Tiles
Internationalizing Tiles
Create a Tile Layout
Use a Tile Layout
Create a Tile Definition
Use a Tile Definition
Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions