A Closer Look at Simple Components in Apache Tapestry - Source Code (
Page 3 of 4 )
To wrap up what was already done, here is the source code for the template, specification and class for the Home page:
Home.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Guess the Word</title>
</head>
<body>
<h2>Guess the Word</h2>
<form action="" jwcid="secretWordForm">
Enter the secret word:
<input type="text" jwcid="secretWord"/>
<input type="submit" value="Submit">
</form>
</body>
</html>
Home.page:
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
<page-specification class="com.devshed.tapestry.guesstheword.Home">
<component id="secretWord" type="TextField">
<binding name="value" value="theWord"/>
<binding name="hidden" value="true"/>
</component>
<component id="secretWordForm" type="Form">
<binding name="listener" value="listener:onWordSubmit"/>
</component>
</page-specification>
Home.java:
package com.devshed.tapestry.guesstheword;
import org.apache.tapestry.html.BasePage;
public abstract class Home extends BasePage {
public Home() {
}
public abstract String getTheWord();
public String onWordSubmit() {
return "Secret";
}
}
However, there is one technical issue we need to care of before leaving.