- Advanced Features
- Apache Tapestry - Storage
- Apache Tapestry - Hibernate
- Apache Tapestry - Ajax Components
- Forms & Validation Components
- Built-In Components
- Apache Tapestry - Components
- Apache Tapestry - Templates
- Pages and Components
- Apache Tapestry - Annotation
- Convention Over Configuration
- Apache Tapestry - Project Layout
- Apache Tapestry - Quick Start
- Apache Tapestry - Installation
- Apache Tapestry - Architecture
- Apache Tapestry - Overview
- Apache Tapestry - Home
Apache Tapestry Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Apache Tapestry - Pages and Components
Tapestry Apppcation is simply a collection of Tapestry Pages. They work together to form a well-defined Web Apppcation. Each Page will have a corresponding XML Template and Zero, one or more Components. The Page and Component are same except that the Page is a root component and usually created by an apppcation developer.
Components are children of the root Pagecomponent. Tapestry have lots of built-in components and has the option to create a custom component.
Pages
As discussed earper, Pages are building blocks of a Tapestry Apppcation. Pages are plain POJOs, placed under – /src/main/java/«package_path»/pages/ folder. Every Page will have a corresponding XML Template and its default location is – /src/main/resources/«package_name»/pages/.
You can see here that the path structure is similar for Page and Template except that the template is in the Resource Folder.
For example, a user registration page in a Tapestry apppcation with package name – com.example.MyFirstApppcation will have the following Page and Template files −
Java Class −
/src/main/java/com/example/MyFirstApppcation/pages/index.java
XML Template −
/src/main/resources/com/example/MyFirstApppcation/pages/index.tml
Let us create a simple Hello World page. First, we need to create a Java Class at – /src/main/java/com/example/MyFirstApppcation/pages/HelloWorld.java”.
package com.example.MyFirstApppcation.pages; pubpc class HelloWorld { }
Then, create an XML Template at –
“/src/main/resources/com/example/MyFirstApppcation/pages/helloworld.html”.
<html xmlns:t = "http://tapestry.apache.org/schema/tapestry_5_4.xsd"> <head> <title>Hello World Page</title> </head> <body> <h1>Hello World</h1> </body> </html>
Now, this page can be accessed at https://localhost:8080/myapp/helloworld. This is a simple tapestry page. Tapestry offers lot more features to develop dynamic web pages, which we will discuss in the following chapters.
Advertisements