Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed language param of code macro

...

Wiki Markup
{float:right|background=#eee}
{contentbylabel:title=Related Articles|showLabels=false|showSpace=false|labels=new-users}
{float}

This is

Excerpt

a cheat sheet brief guide for learning Tapestry, designed for those who already know JavaServer Faces (JSF)

.

...

Faces templates and Tapestry templates are superficially quite similar.

Section
Column
Code Block
languagexml
titleJSF template (helloworld.xhtml)xml

<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html">
  <h:body>
    <p><h:outputText value="#{helloWorldBean.greeting} /></p>
  </h:body>
</html>
Column
Code Block
languagexml
titleTapestry template (HelloWorld.tml)xml

<html>
  <body>
    <p>${greeting}</p>
  </body>
</html>

...

  • The #{...} syntax in JSF does not encode the underlying string, so you have to use the <h:outputText> tag if your data may contain HTML reserved characters such as <, >, or &. In contrast, the ${...} syntax in Tapestry does encode the underlying string.
  • In JSF, backing beans are not necessarily related one-to-one with page templates. Often several templates use the same backing bean, and one template may reference multiple backing beans. In Tapestry, they are always related one-to-one, and therefore you don't have to specify which component class your ${...} expressions are referencing.
Section
Column
Code Block
languagejava
titleJSF Backing Bean (HelloWorldBean.java)java

@ManagedBean
@RequestScoped
public class HelloWorldBean {
    public String getGreeting() {
        return "Hello, World!";
    }
}
Column
Code Block
languagejava
titleTapestry page class (HelloWorld.java)java

public class HelloWorld {
    public String getGreeting() {
        return "Hello, World!";
    }
}

...

Tapestry applications can use JSR 303 Bean Validation annotations that JSF users should be familiar with:

Code Block
java
languagejava

public class Employee {
    @Validate("required,minlength=2,maxlength=100")
    private String lastName;
    @NotNull @Email private String email;

...