Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


{
Div
Wiki Markup
style
float:right
titleRelated Articles
classaui-label
Content by Label
showLabelsfalse
showSpacefalse
titleRelated Articles
cqllabel = "new-users" and space = currentSpace()
|background=#eee} {contentbylabel:title=Related Articles|showLabels=false|showSpace=false|labels=new-users} {float}


Getting started with Tapestry is easy, and you have lots of ways to begin your adventure: : watch a video, browse the source code of a working demo app, create a skeleton app using Maven, or step through the tutorial.

...

For a fast-paced introduction, watch Mark W. Shead's 10 Minute Demo. This video shows how to set up a simple Tapestry application, complete with form validation, Hibernate-based persistence, and Ajax. The video provides a preview of the development speed and productivity that experienced Tapestry users enjoy.

...

You can also play with Tapestry via our live demonstration applications. To start, have a look at the Hotel Booking Demo. The source code is provided so you can download and play with it. Also check out the Jumpstart demonstration site.

Create your first Tapestry project

...

Once you have Maven installed, execute the following command:

Code Blocknoformat

mvn archetype:generate -DarchetypeCatalog=http://tapestryDfilter=org.apache.org
tapestry:quickstart

(Alternatively, if you want to get an archetype for a not-yet-released version of Tapestry – most users don't – you can use the staging URI, https://repository.apache.org/content/repositories/staging ).

Maven will prompt you for the archetype to create ("Tapestry 5 Maven will prompt you for the archetype to create ("Tapestry 5 Quickstart Project") and the exact version number (e.g., "5.35.3", at the time of writing0"). It also asks you for a group id, an artifact id, and a version number. You can see this in the following transcript:

noformat
Code Block
language
text

$ mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------------------                                                                         
[INFO] -------------------------------------------------
[INFO] Building Maven Stub Project -----------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.12:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.12:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.12:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://tapestry.apache.org -> org.apache.tapestry:quickstart (Tapestry 5 Quickstart Project)
2: http://tapestry.apache.org -> org.apache.tapestry:tapestry-archetype (Tapestry 5.4.1.65 Archetype)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1
Choose org.apache.tapestry:quickstart version: 
1: 5.0.19
2: 5.1.0.5
3: 5.2.6
4: 5.3.7
5: 5.34.15
6: 5.35.20
7: 5.6.4
8: 5.7.3.3
9: 5.8.4
Choose a number: 79: 7
Downloading9
Define value for property 'groupId': http://tapestry.apache.org/org/apache/tapestry/quickstart/5.3.3/quickstart-5.3.3.jar
Downloading: http://repo1.maven.org/maven2/org/apache/tapestry/quickstart/5.3.3/quickstart-5.3.3.jar
Downloaded: http://repo1.maven.org/maven2/org/apache/tapestry/quickstart/5.3.3/quickstart-5.3.3.jar (64 KB at 69.3 KB/sec)
Downloading: http://tapestry.apache.org/org/apache/tapestry/quickstart/5.3.3/quickstart-5.3.3.pom
Downloading: http://repo1.maven.org/maven2/org/apache/tapestry/quickstart/5.3.3/quickstart-5.3.3.pom
Downloaded: http://repo1.maven.org/maven2/org/apache/tapestry/quickstart/5.3.3/quickstart-5.3.3.pom (400 B at 1.0 KB/sec)
Define value for property 'groupId': : com.example
Define value for property 'artifactId': : newapp
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  com.example: : com.example.newapp
Confirm properties configuration:
groupId: com.example
artifactId: newapp
version: 1.0-SNAPSHOT
package: com.example.newapp
 Y: :
[INFO] -- com.example
Define value for property 'artifactId': : newapp
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  com.example: : com.example.newapp
Confirm properties configuration:
groupId: com.example
artifactId: newapp
version: 1.0-SNAPSHOT
package: com.example.newapp
 Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: quickstart:5.8.4
[INFO] ------------------------------------------------------------------------------------------
[INFO] UsingParameter: followinggroupId, parameters for creating project from Archetype: quickstart:5.3.3Value: com.example
[INFO] Parameter: artifactId, Value: newapp
[INFO] ----------------------------------------------------------------------------Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.example.newapp
[INFO] Parameter: packageInPathFormat, Value: com/example/newapp
[INFO] Parameter: groupIdpackage, Value: com.example.newapp
[INFO] Parameter: artifactId, Value: newapp
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: packagegroupId, Value: com.example.newapp
[INFO] Parameter: packageInPathFormatartifactId, Value: com/example/newapp

[INFO] Parameter: package, Value: com.example. project created from Archetype in dir: /home/joeuser/junk/junk2/newapp
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: com.example
[INFO] Parameter: artifactId, Value: newapp
[WARNING] Don't override file /Users/hlship/workspaces/github/newapp/src/test/java
[WARNING] Don't override file /Users/hlship/workspaces/github/newapp/src/main/webapp
[WARNING] Don't override file /Users/hlship/workspaces/github/newapp/src/main/resources/com/example/newapp
[WARNING] Don't override file /Users/hlship/workspaces/github/newapp/src/test/resources
[WARNING] Don't override file /Users/hlship/workspaces/github/newapp/src/test/conf
[WARNING] Don't override file /Users/hlship/workspaces/github/newapp/src/site
[INFO] project created from Archetype in dir: /Users/hlship/workspaces/github/newapp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.020s
[INFO] Finished at: Sun Apr 09 16:55:01 EDT 2020
[INFO] Final Memory: 16M/303M
[INFO] ----------------------------------------------------------------------------------------------------------
[INFO] BUILD 


Maven will (after performing a number of one-time downloads) create a skeleton project ready to run. Because we specified an artifactId of "newapp", the project is created in the newapp directory. (Note: if you get "Unable to get resource" warnings at this stage, you may be behind a firewall which blocks outbound HTTP requests to Maven repositories.)

To run the skeleton application, change to the newapp directory and execute the "mvn jetty:run" command to start the Jetty app server:

Code Block
languagebash
$ cd newapp
$ mvn jetty:run
[INFO] Scanning for projects...
[INFO]
[INFO] ----SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.062s
[INFO] Finished at: Tue Nov 22 11:11:14 PST 2011
[INFO] Final Memory: 7M/81M
[INFO] ------------------------------------------------------------------------
~/workspaces/github
$

Maven will (after performing a number of one-time downloads) create a skeleton project ready to run. Because we specified an artifactId of "newapp", the project is created in the newapp directory. (Note: if you get "Unable to get resource" warnings at this stage, you may be behind a firewall which blocks outbound HTTP requests to Maven repositories.)

To run the skeleton application, change to the newapp directory and execute:

No Format

mvn jetty:run

After some more one-time downloads you can open your browser to http://localhost:8080/newapp to see the application running:

Image Removed

The application consists of three pages sharing a common look and feel. The initial page, Index, allows you to perform some basic operations.

You can also load the newly-created project it into any IDE and start coding. See the next section on where to find the different components of the application.

Exploring the generated project

The archetype creates the following files:

-----------------------------------------
[INFO] Building newapp Tapestry 5 Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------

...

Application 'app' (version 1.0-SNAPSHOT-DEV) startup time: 329 ms to build IoC Registry, 919 ms overall.
 ______                  __             ____
/_  __/__ ____  ___ ___ / /_______ __  / __/
 / / / _ `/ _ \/ -_|_-</ __/ __/ // / /__ \
/_/  \_,_/ .__/\__/___/\__/_/  \_, / /____/
        /_/                   /___/  5.8.4 (development mode)

[INFO] Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server


After some more one-time downloads you can open your browser to http://localhost:8080/newapp to see the application running:

Image Added

The application consists of three pages sharing a common look and feel. The initial page, Index, allows you to perform some basic operations.

You can also load the newly-created project it into any IDE and start coding. See the next section on where to find the different components of the application.

Exploring the generated project

The archetype creates the following files:

No Format
newapp/
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── example
    │   │           └── newapp
    │   │               ├── components
    │   │               │   └── Layout.java
    │   │               ├── pages
    │   │               │   ├── About.java
    │   │               │   ├── Contact.java
    │   │               │   ├── Error404.java
    │   │               │   ├── Index.java
    │   │               │   └── Login.java
    │   │               └── services
    │   │                   ├── AppModule.java
    │   │                   ├── DevelopmentModule.java
    │   │          
No Format

newapp
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── example
    │   │           └── newappQaModule.java
    │   │    ├── resources
          ├── componentscom
    │   │          └── example
    │   └── Layout.java
    │   │        └── newapp
      ├── pages
    │   │           ├── components
   │   ├── About.java
    │   │               │   ├──└── ContactLayout.javatml
      │   │               │   └──├── Indexlogback.javaxml
       │   │               └── servicespages
    │  │   │ │                   ├── AppModuleAbout.javatml
     │   │                   ├── DevelopmentModuleContact.javatml
       │   │                   └──├── QaModuleError404.java
tml
    │   │   │       │   ├── resources
    │   │   ├── comIndex.properties
    │   │   │   └── example
    │   │   │       └── newapp
    │   │   │  ├── Index.tml
         ├── components
    │   │   │           │   └── LayoutLogin.tml
    │   │   │           └── pageslog4j.properties
    │   │   │   └── webapp
           ├── About.tmlWEB-INF
    │   │   │          ├── app.properties
      ├── Contact.tml
    │   │   │   └── web.xml
           ├── Indexfavicon.propertiesico
    │   │   │       ├── images
       └── Index.tml
    │   │   └── log4jtapestry.propertiespng
     │   └── webapp
    │  └── mybootstrap
    ├── WEB-INF
    │       │   ├── app.propertiescss
    │       │   └── web.xml
    │       ├── faviconbootstrap-responsive.icocss
    │       └── layout
    │      └── bootstrap.css
    ├── images
    │        ├── img
  │   ├── img01.jpg
    │           │   ├── img03.jpgglyphicons-halflings-white.png
    │           │   ├── img04.jpg
    │  └── glyphicons-halflings.png
         │   ├── img08.gif
    │  └── js
        │   ├── img09.gif
    │       └── bootstrap.js
   │   ├── img10.gifsite
    │     ├── apt
     │   ├── img11.gif
    │     └── index.apt
      │   ├──└── img12site.gifxml
    │  └── test
        │   ├── img13.gifconf
    │           │   ├── img14testng.gifxml
    │           │   ├── img18.gif└── webdefault.xml
    │      ├── java
    │   ├── img19.gif
    │   └── PLACEHOLDER
       │   └── img20.gifresources
    │           ├──└── layout.cssPLACEHOLDER
30 directories,   │           └── license.txt
    ├── site
    │   ├── apt
    │   │   └── index.apt
    │   └── site.xml
    └── test
        ├── conf
        │   ├── testng.xml
        │   └── webdefault.xml
        ├── java
        │   └── PLACEHOLDER
        └── resources
            └── PLACEHOLDER

A Tapestry application is composed of pages, each page consisting of one template file and one Java class.

39 files

A Tapestry application is composed of pages, each page consisting of one template file and one Java class.

Tapestry page templates have the .tml extension and are found within src/main/resources/ under the app's pages package (src/main/resources/com/example/newapp/pages, in this example). Templates are essentially HTML with some special markup to reference properties in the corresponding Java class and to reference ready-made or custom components.

Similarly, Tapestry page classes are found in within the src/main/java under the app's pages package (src/main/java/com/example/newapp/pages, in this example) and their name matches their template name (Index.tml -> Index.java).

In the skeleton project, most of the HTML is not found on the pages themselves but in a Layout component which acts as a global template for the whole site. Java classes for components live in src/main/java/com/example/newapp/components and component templates go Tapestry page templates have the .tml extension and are found in src/main/resources/com/example/newapp/pages

Footnote

That is, in the com.example.newapp.pages package.

. Templates are essentially HTML with some special markup to link the template to the Java class and to reference ready-made components you can use to speed up your development.

Java classes are found in src/main/java/com/example/newapp/pages and their name matches their template name (Index.tml -> Index.java).

...

components.

The archetype includes a few optional extras:

  • The bundled version of the Bootstrap CSS library has a per-project override. You can see the files in src/webapp/context/mybootstrap, and the overrides to enable that in AppModule.java.
  • By default, Tapestry users Prototype as its client-side library, but the archetype overrides this to jQuery, which is preferred for new projects.
  • The archetype adds a simple filter that shows the timing of each request.
  • The archetype sets up not just for builds with Maven, but also via Gradle.

What's next?

To deepen your understanding, step through the Tapestry Tutorial, which goes into much more detail about setting up your project , as well as loading it into Eclipse... then continues on to teach you more about Tapestry.

Be sure to read about the core Tapestry Principles, and browse the extensive User Guide Documentation.

Obtain Help

Tapestry has an active user mailing list on which you can find a lot of valuable support, commonly within just a few minutes. You can subscribe by sending e-mail to users-subscribe@tapestry.apache.org or look for an answer in the archives. More Options...

Having trouble? Try our Frequently Asked Questions.display-footnotes Tutorial.

...