Exercise 10: Using Struts and Tiles
/*
First edition copyright 2004 ObjectSource LLC. All rights reserved.
This training material and the accompanying lab exercises were prepared
by Srikanth Shenoy for ObjectSource LLC.
GRANT OF LICENSE: ObjecSource LLC grants you a non-exclusive license to
use the material. No part of this publication may be reproduced, stored
in a retrieval system or transmitted in any form or by any means
electronic, mechanical, photocopying, recording or otherwise, without
the prior written permission of ObjectSource LLC. At its discretion,
ObjectSource LLC may provide limited support through email or discussion
forums at ObjectSource web site. ObjectSource incurs no obligation
to provide any support under this Agreement.
*/
/*
Technical Objectives for this exercise:
The technical objectives of this exercise is to learn ?how to?:
1) Use Struts and Tiles
a) Add TilesRequestProcessor to struts-config.xml
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
b) Define the Tiles Plugin
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true"/>
</plug-in>
c) Create an empty Tiles definition file tiles-defs.xml under /WEB-INF directory
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
</tiles-definitions>
d) Add the base definition to the tile definition xml
<definition name="base.definition" path="/Layout.jsp">
<put name="title" value=""/>
<put name="header" value="/common/header.jsp" />
<put name="footer" value="/common/footer.jsp" />
<put name="body" value="" />
</definition>
e) Create the definition for each of the three pages by extending the above definition and overriding
the empty values
f) Change the references to physical jsps in struts-config.xml and replace them with one of the above
names. For instance, change all references to
NOTE: There is no replacement for index.jsp. Let us keep it as is. Hence don?t change references to
index.jsp
....
*/
struts-training.zip( 26,264 k)Related examples in the same category