Learn about tapestry, part 1th

Source: Internet
Author: User
Tags tomcat apache tomcat

If you want to sell a product, it's important to have an online facility, whether it's running a millions of-dollar company or just trying to handle thousands of line bracelets on holidays. In some cases, patching up some Web pages and using pre-packaged support systems such as PayPal or EBay to handle sales transactions can be good enough. But a comprehensive, well-designed Web application should be able to elevate online sales from a small-time to a professional, dynamic online store. As everyone knows, consumers buy more things in stores than they do from flea markets.

The problem is that when you go into most Web development frameworks-especially when you use Java™ as your programming language-you find complexity too high. Struts, JSF, and spring are excellent web development frameworks, but none of them are suitable for timid people. (If you've ever tried to explain the control reversal to a new Java developer, you'll know what I'm talking about!) Fortunately, there are easier choices.

Tapestry is an Open-source, java-based framework published under the Apache Software license, designed specifically to simplify WEB development. It has the following key features:

Easy to install: You don't need to be a master of WEB applications to let Tapestry start and run.

Easy to use: Only basic Java and HTML (yes, really html, not servlet) skills can be written to Tapestry applications.

Easily scaled up. When a site grows more than 10, 50, or 100 pages, you don't have to discard Tapestry. For most WEB applications, Tapestry is robust enough.

In this article (the first half of the series), I will take you into the tapestry world. I'll take you through every step of downloading and installing this framework, and then run some sample applications to help you understand how it works. In the next article, I'll introduce more advanced examples that will give you a better grasp of the core framework of tapestry. You will be fully adapted to the Tapestry environment before you understand the core framework.

Simplified installation

You will soon learn that tapestry's slogan is simple. This simplicity does not mean primitive or immature, but represents easy to understand, easy to use, and intuitive. Since installation is an introduction to any new technology, it is no exaggeration to say that installing Tapestry is very easy. For starters, there are very few prerequisites, and these requirements are fairly standard for Web developers, so they may already be installed.

Annotations in the Tapestry

A new feature in Java 5.0 is the annotation syntax. With annotations, you can mark code with a style that is very similar to inline annotations, starting with the @ sign. You can use annotations to add metadata to a class, and then a framework such as a compiler or Tapestry can use metadata. Specifically, Tapestry allows annotations to be used directly in the code to describe the behavior that would otherwise have been defined in an additional page or component.

Prerequisite Conditions 1:java 5.0

Obviously, the first requirement for using tapestry is that the Java platform is running on the machine. Although Tapestry can work with almost any relatively new Java version (Java version 1.3 and above), it is best to use Java 5.0. Several optional features of tapestry can only work under Java 5. And, there is really no reason not to convert to Java 5: It is stable and well tested and has undergone the most initial development pain.

Prerequisite 2: Building tools

With the JVM and servlet engines, you need a build tool like Apache Ant. Although it's easy to download ant, it needs to be determined that there are ant binaries in the path (for Linux/mac OS X system is ant, for Windows system is ant.bat). If you enter ant in an empty directory, you may see output such as the following:

Buildfile: build.xml does not exist!
Build failed

Prerequisite 3: Micro-core

Finally, you need to install a microkernel, called hivemind, to use it as the Tapestry application login object. I will not discuss hivemind--in this article in detail, it is worth using a few articles to discuss! --but you'll see how Tapestry uses it. After you download the hivemind from the Jakarta Web site, put it in the same directory as Tapestry, for example, you might use/usr/local/java/hivemind-1.1 or c:/java/hivemind-1.1. Any location, just remember where you put it!

Tapestry actually has a lot of dependencies, but after installing Hivemind, Ant, and Java 5.0, you can get Tapestry to handle the rest of the dependencies themselves. Because Tapestry is a WEB application framework, you need a servlet engine, such as Apache Tomcat, when you are ready to run your application. Tapestry applications are packaged into WAR files (Web application files) so that they can be placed in the Web application directory of the servlet engine. All the examples in this article use Tomcat, but it's easy to put Tapestry on the other servlet engines you choose.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.