Installing Tiles


The Tiles installation process depends on the Struts version. Tiles can also be used without Struts. To enable Tiles definitions described in one or more files, you need to write these definition's files and to initialize the definition factory. If you don't use definitions, you don't need to initialize the factory.

For Struts1.0

the required file are
tilesForStruts1.0.jar in WEB-INF/lib/
tiles.tld in WEB-INF/
struts.jar, commons-digester.jar, commons-collections.jar, commons-beanutils.jar in WEB-INF/lib/
Struts related files
All these files should come with the Tiles or Struts distribution. They are normally located in WEB-INF/lib/ for .JAR files and WEB-INF/ for .TLD files.

To Enable Definitions for Struts 1.0

You need to use a special servlet extending the Struts servlet. This is specified in the web.xml file of your application:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.tiles.ActionComponentServlet</servlet-class>
<!-- Tiles Servlet parameter Specify configuration file names. There can be several comma separated file names
-->
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<!-- Tiles Servlet parameter
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header.
false : no validation
-->
<init-param>
<param-name>definitions-parser-validate</param-name>
<param-value>true</param-value>
</init-param>
...
</servlet>

If you have developed your own servlet extending the standard Struts servlet, consider extending the Tiles servlet instead, or provide methods and hooks enabling Tiles

For Struts1.1

the required file are
struts.jar in WEB-INF/lib/. Tiles are now in the main Struts distribution.
tiles.tld in WEB-INF/
all commons-*.jar files needed by Struts in WEB-INF/lib/
All these files should come with the Tiles or Struts distribution. They are normally located in WEB-INF/lib/ for .JAR files and WEB-INF/ for .TLD files.

<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml, /WEB-INF/tiles-tests-defs.xml,/WEB-INF/tiles-tutorial-defs.xml,
/WEB-INF/tiles-examples-defs.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>

To Enable Definitions for Struts 1.1

Use the Tiles plug-in to enable Tiles definitions. This plug-in creates the definition factory and pass it a configuration object populated with parameters explained here after. Parameters can be specified in the web.xml file or as the plug-in parameters. The plug-in first read parameters from web.xml, and then overload them with the one found in the plug-in. All parameters are optional and can be omitted. The plug-in should be declared in each struts-config file:
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml,
/WEB-INF/tiles-tests-defs.xml,/WEB-INF/tiles-tutorial-defs.xml,
/WEB-INF/tiles-examples-defs.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>


For Tiles stand alone


Required files are:
tiles.jar in WEB-INF/lib/
tiles.tld in WEB-INF/
commons-digester.jar, commons-collections.jar, commons-beanutils.jar in WEBINF/lib/
All these files should come with the Tiles distribution. They are normally located in WEBINF/lib/ for .JAR files and WEB-INF/ for .TLD files.

To Enable Definitions for Tiles stand alone

Tiles can be used without Struts. To initialize the definition factory, you can use the provided servlet. Declare it in the web.xml file of your application:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<init-param>
<param-name>definitions-parser-validate</param-name>
<param-value>true</param-value>
</init-param>
...
The parameters are the same as for Struts1.1 or 1.0.

 

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