Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Using tiles-defs.xml in Tiles Application

Using tiles-defs.xml in Tiles Application Using tiles-defs.xml in Tiles Application In the last section we studied how to forward the request (call) to a jsp page which specifies which tiles layout definition should be used to apply to the

Tutorial Details:

content. In this section I will show you how to use the a definition in the tiles-defs.xml for generating the content.
In Tiles we can define the definition in the tiles-defs.xml which specifies the different components to "plugin" to generate the output. This eliminates the need to define extra jsp file for each content file. For example in the last section we defined example.jsp to display the content of content.jsp file. In this section I will show you how to eliminate the need of extra jsp file using tiles-defs.xml file.
Steps to Use the tiles-defs.xml Setup the Tiles plugin in struts-config.xml file.
Add the following code in the struts-config.xml (If not present). This enables the TilesPlugin to use the /WEB-INF/tiles-defs.xml file.






Defining the tiles-defs.xml
In this file we are defining the different components to "plugin". Here is the code:







The name of the definition is Tiles.Example, we will use this in struts-config.xml (While creating forwards in struts-config.xml file) file. The page attribute defines the template file to be used and the put tag specifies the different components to "plugin". Your tiles-defs.xml should look like:

"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">











Configure the Struts Action to use Tiles Definition
Open the struts-config.xml file and add the following code:
forward="Tiles.Example"/>
With Tiles, the action points to the Tiles definition, as shown in the above code. In this code we are using the Tiles.Example definition which we have defined in the tiles-defs.xml file. Without Tiles, forward and action definitions point directly to JSPs. With Tiles, they point to the page's definition in the Tiles configuration file.
Testing the Application
Create a link in index.jsp to call the Example. Code added are:

  • Using tiles-defs.xml


    Example shows you how to use tiles-defs.xml file.

  • To test the application build it using ant and deploy on the JBoss server. Type http://localhost:8080/strutstutorial/index.jsp in the bowser and select the Using tiles-defs.xml link. Your browser should show the page.


     

    Rate Tutorial:
    http://www.roseindia.net/struts/using-tiles-defs-xml.shtml

    Read Tutorial at: Click here to view the tutorial

    Rate Tutorial:
    Using tiles-defs.xml in Tiles Application

    View Tutorial:
    Using tiles-defs.xml in Tiles Application

    Related Tutorials:

    UI design with Tiles and Struts
    UI design with Tiles and Struts
     
    Excellent tutorial on Struts and Tiles
    Excellent tutorial on Struts and Tiles This tutorial assumes knowledge of Java, JDBC, Servlets, J2EE (with regards to Web applications) and JSP Struts in a holistic manner, minus the beads and crystals. The Tiles framework makes creating reusable pages
     
    Performance Analysis of J2EE Applications Using AOP Techniques
    Performance Analysis of J2EE Applications Using AOP Techniques In this article we demonstrate the use of AOP techniques through which J2EE applications can be easily instrumented without any modifications to application code. We have developed a very sim
     
    Developing Swing Components Using Simulators
    Developing Swing Components Using Simulators In this article, you'll learn about a technique for developing encapsulated components. You'll also learn about how to test graphical parts of your application that JUnit can't, such as layouts and other visua
     
    InfoNode (Java Components)
    InfoNode Docking Windows is a pure Java Swing based docking windows framework. The best way to see features of InfoNode Docking Windows is to try the Web Start demos.
     
    Monitoring Local and Remote Applications Using JMX 1.2 and JConsole
    Monitoring Local and Remote Applications Using JMX 1.2 and JConsole The latest release of Java, J2SE 5.0 (codenamed Tiger), adds core support for the Java Management Extensions (JMX) 1.2 into the Java standard libraries. This article walks you through h
     
    Reporting Application Errors by Email
    Reporting Application Errors by Email It is common practice for server-side applications to log messages to files on the server's file system. These logs are a vital source of information for system administrators and the application development team. If
     
    Using Timers in J2EE Applications
    Using Timers in J2EE Applications Job scheduling is nothing new--most enterprise applications require the scheduling of tasks and activities. For example, your application may need a timer service to run a business process once a day, or to clean up a te
     
    Accessing Databases Using Java and JDBC
    This article will show how a Java Application, Applet or Servlet can access data stored in relational databases using the JDBC API.
     
    Integrating Struts, Tiles, and JavaServer Faces
    Integrating Struts, Tiles, and JavaServer Faces. Bring the power, flexibility, and manageability of the three technologies together.
     
    Reuse Tiles and Simplify UI
    JavaServer Pages (JSP) technology supports application object reuse through includes, which allow other files (including other JSPs) to be sourced into a JSP file either at compile time or dynamically at application runtime. This is great for abstracting
     
    Programming Jakarta Struts: Using Tiles, Part 2
    In part two in this series of book excerpts on using tiles from Programming Jakarta Struts, learn how to install and configure tiles, as well as get an overview on tiles.
     
    Developing Simple Struts Tiles Application
    In this tutorial I will show you how to develop simple Struts Tiles Application. You will learn how to setup the Struts Tiles and create example page with it.
     
    Using Lucene With OJB
    Brian McCallister looks at the Lucene search engine and shows us how to index and retrieve objects from a sample Student application.
     
    Struts and Tiles aid component-based development
    In the Java world, Struts is one of the best-known and most talked about open source embodiments of MVC.
     
    Using tiles-defs.xml in Tiles Application
    In this lesson you will learn how to define and use the "plugin" definitation in tiles-defs.xml file.
     
    Beginner to advance guide to the Apache Struts
    Beginner to advance guide to the Apache Struts The Complete Apache Struts Tutorial This complete reference of Jakarta Struts shows you how to develop Struts applications using ant and deploy on the JBoss Application Server. Ant script is provided
     
    Developing Simple Struts Tiles Application
    Developing Simple Struts Tiles Application Developing Simple Struts Tiles Application Introduction In this section I will show you how to develop simple Struts Tiles Application. You will learn how to setup the Struts Tiles and create example
     
    Using tiles-defs.xml in Tiles Application
    Using tiles-defs.xml in Tiles Application Using tiles-defs.xml in Tiles Application In the last section we studied how to forward the request (call) to a jsp page which specifies which tiles layout definition should be used to apply to the
     
    Creating EJB clients using the Eclipse Rich Client Platform
    This article shows how to build a sample EJB client using the Eclipse Rich Client Platform (RCP), which has become increasingly popularity due to its extensible nature.
     
    Site navigation
     

     

    Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

    Copyright © 2006. All rights reserved.