An
optional framework of a struts used on composite view design pattern that
facilitated faster development of views. Normally in a web application a view
consist of different sub-views which are arrange according to a predefine
structure that is common for all views. Usually structure is defined with the
help of frameset, html table and style sheet. Tiles frame work provides a mechanism
to change the structured of all views without individually applying changes to
them.
<titles:insert>
tag is used to define place holder tiles.
myLayout.jsp
<table
width="100%"
height="553">
<tr
bgcolor="#CC9999"><td height="60"
colspan="2"><titles:insert
attribute="header"/></td>
</tr>
<tr><td
width="25%" height="436" bgcolor="#9999CC">
<titles:insert
attribute="menu"/></td>
<td><titles:insert
attribute="contents"/></td></tr>
<tr bgcolor="#CCCCCC"><td
colspan="2"><titles:insert
attribute="footer"/></td></tr>
</table>
WelcomeStruts.jsp
<tiles:insert
page="myLayout.jsp">
<tiles:put name="header"
value="header.jsp"/>
<tiles:put name="footer"
value="footer.jsp"/>
<tiles:put name="contents"
value="contents.jsp"/>
<tiles:put name="menu"
value="menu.jsp"/>
<tiles:put name="title"
value="Home Page"/>
</tiles:insert>
Tiles Definition is used
to provide the default value of parameter in a tiles layout. This is used to an
tiles to be display in some region of the layout remain common for the more
than one pages.
myDef.jsp
<logic:notPresent
name="myDef" scope="application">
<tiles:definition
id="myDef" page="myLayout.jsp" scope="application">
<tiles:put
name="header" value="header.jsp"/>
<tiles:put
name="menu" value="menu.jsp"/>
<tiles:put
name="footer" value="footer.jsp"/>
</tiles:definition>
</logic:notPresent>
WelcomeStruts.jsp
<jsp:incude
page=”myDef.jsp”>
<tiles:insert beanName=”myDef” beanScope=”application”>
<tiles:put name=””contents”
value=”contents.jsp”/>
</tiles:insert>
No comments:
Post a Comment