Apache Tiles - PowerPoint PPT Presentation

About This Presentation
Title:

Apache Tiles

Description:

Apache Tiles Tiles Introduction Tiles is a framework for the development user interface Tiles is enables the developers to develop the web applications by assembling ... – PowerPoint PPT presentation

Number of Views:267
Avg rating:3.0/5.0
Slides: 17
Provided by: bci9
Category:
Tags: apache | site | tiles

less

Transcript and Presenter's Notes

Title: Apache Tiles


1
  • Apache Tiles

2
Tiles Introduction
  • Tiles is a framework for the development user
    interface
  • Tiles is enables the developers to develop the
    web applications by assembling the reusable tiles
    (jsp, html, etc..)
  • Tiles uses the concept of reuse and enables the
    developers to define a template for the web site
    and then use this layout to populate the content
    of the web site

3
Tiles Introduction
  • For example, if you have to develop a web site
    having more that 500 page of static content and
    many dynamically generated pages. The layout of
    the web site often changes according to the
    business requirement. In this case you can use
    the Tiles framework to design the template for
    the web site and use this template to populate
    the contents. In future if there is any
    requirement of site layout change then you have
    to change the layout in one page. This will
    change the layout of you whole web site.

4
Tiles1 and Tiles2
  • Tiles has been designed to use with the Struts
    Framework
  • Tiles can be used with or without Struts.
  • Tiles which has been design to use with out
    Struts is called as Tiles2

5
Steps To Create Tiles Application
  • Tiles is very useful framework for the
    development of web applications. Here are the
    steps necessary for adding Tiles to your Struts
    application
  • Add the Tiles Tag Library Descriptor (TLD) file
    to the web.xml.
  • Create layout JSPs.
  • Develop the web pages using layouts.
  • Repackage, run and test application.

6
Add the Tiles TLD to web.xml file
  • lttaglibgt     lttaglib-urigt/tags/struts-tileslt/tagl
    ib-urigt      lttaglib-locationgt/WEB-INF/struts-t
    iles.tldlt/taglib-locationgtlt/taglibgt

7
Create layout JSPs.
  • Our web application layout is divided into four
    parts To Banner, Left Navigation Bar, Content
    Area and Bottom of the page for copy right
    information. Here is the code for out template
    (template.jsp)

8
template.jsp
  • lt_at_ page language"java" gtlt_at_ taglib
    uri"/WEB-INF/struts-tiles.tld" prefix"tiles"
    gtlthtmlgtltheadgt    lttitlegtlttilesgetAsString
    name"title" ignore"true"/gtlt/titlegtlt/headgtltbod
    ygtlttable border"1" cellpadding"0"
    cellspacing"0" width"100" bordercolor"000000"
    bgcolor"E7FDFE"gtlttrgtlttd width"100"
    colspan"2" valign"top"gtlttilesinsert
    attribute"header"/gtlt/tdgtlt/trgtlttrgtlttd
    width"23"gtlttilesinsert attribute"menu"/gtlt/tdgt
    lttd width"77" valign"top" valign"top"gtlttilesi
    nsert attribute"body"/gtlt/tdgtlt/trgtlttrgtlttd
    width"100" colspan"2" valign"top"gtlttilesinser
    t attribute"bottom"/gtlt/tdgtlt/trgtlt/tablegtlt/body
    gtlt/htmlgt

9
example.jsp
  • lt_at_ page language"java" gtlt_at_ taglib
    uri"/WEB-INF/struts-tiles.tld" prefix"tiles"
    gtlttilesinsert page"/tiles/template.jsp"
    flush"true"gt   lttilesput name"title"
    type"string" value"Welcome" /gt   lttilesput
    name"header" value"/tiles/top.jsp" /gt  
    lttilesput name"menu" value"/tiles/left.jsp"
    /gt   lttilesput name"body" value"/tiles/content
    .jsp" /gt   lttilesput name"bottom"
    value"/tiles/bottom.jsp" /gt lt/tilesinsertgt

10
Repackage, run and test application
  • ltligtlthtmllink page"/tiles/example.jsp"gtTiles
    Examplelt/htmllinkgtltbrgtExample of creating
    first tile application.lt/ligt

11
Steps to Use the tiles-defs.xml
  • Add the following code in the struts.xml, This
    enables the TilesPlugin to use the
    /WEB-INF/tiles-defs.xml file.
  • ltplug-in className"org.apache.struts.tiles.TilesP
    lugin" gt       lt!-- Path to XML definition file
    --gt       ltset-property property"definitions-con
    fig" value"/WEB-INF/tiles-defs.xml" /gt      
    lt!-- Set Module-awareness to true --gt      
    ltset-property property"moduleAware" value"true"
    /gtlt/plug-ingt

12
Defining the tiles-defs.xml
  • lt?xml version"1.0" encoding"ISO-8859-1"
    ?gtlt!DOCTYPE tiles-definitions PUBLIC"-//Apache
    Software Foundation//DTD Tiles Configuration
    1.1//EN""http//jakarta.apache.org/struts/dtds/ti
    les-config_1_1.dtd"gtlttiles-definitionsgt    
    ltdefinition name"Tiles.Example"
    page"/tiles/template.jsp"gt          ltput
    name"title" type"string" value"Welcome"
    /gt          ltput name"header"
    value"/tiles/top.jsp" /gt          ltput
    name"menu" value"/tiles/left.jsp" /gt         
    ltput name"body" value"/tiles/content.jsp"
    /gt          ltput name"bottom"
    value"/tiles/bottom.jsp" /gt      lt/definitiongt
  • ltdefinition name"YOUR_DEFINITION_HERE"gt
    lt/definitiongt
  • lt/tiles-definitionsgt

13
Configure the Struts Action to use Tiles
Definition
  • Open the struts.xml file and add the following
    code
  • ltaction path"/Tiles/Example"      
    forward"Tiles.Example"/gt

14
Testing the Application
  • ltligtlthtmllink page"/Tiles/Example.do"gtUsing
    tiles-defs.xmllt/htmllinkgtltbrgtExample shows you
    how to use tiles-defs.xml file.lt/ligt

15
For Your Reference
  • http//tiles.apache.org/tutorial/index.html
  • http//tiles.apache.org/
  • http//www.laliluna.de/tutorial/first-tiles/first_
    struts_tiles_tutorial.pdf
  • http//www.roseindia.net/struts/struts_tiles.shtml

16
  • Thank You
Write a Comment
User Comments (0)
About PowerShow.com