Author: buildbot
Date: Tue Nov 25 01:19:50 2014
New Revision: 930372

Log:
Production update by buildbot for tapestry

Modified:
    websites/production/tapestry/content/cache/main.pageCache
    websites/production/tapestry/content/download.html
    
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.data/guess-1.png
    
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.html

Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/tapestry/content/download.html
==============================================================================
--- websites/production/tapestry/content/download.html (original)
+++ websites/production/tapestry/content/download.html Tue Nov 25 01:19:50 2014
@@ -47,19 +47,13 @@
 </div></div>
 
 <div id="top">
-<div id="smallbanner"><div class="searchbox" style="float:right;margin: .3em 
1em .1em 1em">
-<p>
-<span style="color: #999; font-size: 90%">Tapestry docs, issues, wikis &amp; 
blogs:</span>
-</p><form enctype="application/x-www-form-urlencoded" method="get" 
action="http://tapestry.apache.org/search.html";>
+<div id="smallbanner"><div class="searchbox" style="float:right;margin: .3em 
1em .1em 1em"><span style="color: #999; font-size: 90%">Tapestry docs, issues, 
wikis &amp; blogs:</span>
+<form enctype="application/x-www-form-urlencoded" method="get" 
action="http://tapestry.apache.org/search.html";>
   <input type="text" name="q">
   <input type="submit" value="Search">
 </form>
 
-</div>
-
-<div class="emblem" style="float:left"><a shape="rect" href="index.html"><img 
class="confluence-embedded-image" 
src="https://cwiki.apache.org/confluence/download/attachments/21791252/tapestry_s.png?version=3&amp;modificationDate=1293093635000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/21791252/tapestry_s.png?version=3&amp;modificationDate=1293093635000&amp;api=v2"></a></div>
-<div class="title" style="float:left; margin: 0 0 0 3em">
-<h1 id="SmallBanner-PageTitle">Download</h1></div></div>
+</div><div class="emblem" style="float:left"><p><a shape="rect" 
href="index.html"><img class="confluence-embedded-image 
confluence-external-resource" 
src="http://tapestry.apache.org/images/tapestry_small.png"; 
data-image-src="http://tapestry.apache.org/images/tapestry_small.png";></a></p></div><div
 class="title" style="float:left; margin: 0 0 0 3em"><h1 
id="SmallBanner-PageTitle">Download</h1></div></div>
 <div class="clearer"></div>
 </div>
 
@@ -77,11 +71,11 @@
                             <p>The easiest way to download Tapestry and its 
dependencies is using Maven, as described in <a shape="rect" 
href="getting-started.html">Getting Started</a>.</p>
                     </div>
     </div>
-<p>See the <a shape="rect" href="release-notes.html">Release Notes</a> for 
differences between versions and how to upgrade.</p><h1 
id="Download-StableReleases">Stable Releases</h1><p>Stable releases should be 
relatively free of critical bugs and are considered the <em>safest</em> option 
if stability is a requirement.</p><h2 id="Download-Tapestry5.3.x">Tapestry 
5.3.x</h2><p>Tapestry 5.3.7 was released on 24 Apr 2013. See the <a 
shape="rect" href="release-notes-537.html">release notes</a> for more 
details.</p><p>Note that the <em>recommended</em> distribution method of binary 
and source JARs is via Maven repository. Binaries, source code, and Javadocs 
are also available as a zip archive.</p><div class="sectionColumnWrapper"><div 
class="sectionMacro"><div class="sectionMacroRow"><div class="columnMacro"><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Tapestry 5.3.7</p></th><th colspan="1" 
rowspan="1" class="confluenc
 eTh"><p>Mirrors</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Signature</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>MD5</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Binary (zip)</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/apache-tapestry-5.3.7-bin.zip";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/apache-tapestry-5.3.7-bin.zip.asc";>ASC</a></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p>514b97b944cc438cfcda51183514374a</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Source (zip)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/apache-tapestry-5.3.7-sources.zip";>Download</a></p></td><td
 col
 span="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/apache-tapestry-5.3.7-sources.zip.asc";>ASC</a></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p>ca9adf3b12da7b797516f40f445326f3</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Javadoc (zip)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/apache-tapestry-5.3.7-javadocs.zip";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/apache-tapestry-5.3.7-javadocs.zip.asc";>ASC</a></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p>8e564311a4126111fdfdd05996c74b02</p></td></tr></tbody></table></div></div><div
 class="columnMacro"><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="b
 order-bottom-width: 1px;"><b>Maven Dependency</b></div><div class="codeContent 
panelContent pdl">
+<p>See the <a shape="rect" href="release-notes.html">Release Notes</a> for 
differences between versions and how to upgrade.</p><h1 
id="Download-StableReleases">Stable Releases</h1><p>Stable releases should be 
relatively free of critical bugs and are considered the <em>safest</em> option 
if stability is a requirement.</p><h2 id="Download-Tapestry5.3.x">Tapestry 
5.3.x</h2><p>Tapestry 5.3.8 was released on 20 Nov 2014. See the <a 
shape="rect" href="release-notes-538.html">release notes</a> for more 
details.</p><p>Note that the <em>recommended</em> distribution method of binary 
and source JARs is via Maven repository. Binaries, source code, and Javadocs 
are also available as a zip archive.</p><div class="sectionColumnWrapper"><div 
class="sectionMacro"><div class="sectionMacroRow"><div class="columnMacro"><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Tapestry 5.3.8</p></th><th colspan="1" 
rowspan="1" class="confluenc
 eTh"><p>Mirrors</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Signature</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>MD5</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Binary (zip)</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/apache-tapestry-5.3.8-bin.zip";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/apache-tapestry-5.3.8-bin.zip.asc";>ASC</a></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p>0509cda0f16f96a0ddca9351ec80a59d</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Source (zip)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/apache-tapestry-5.3.8-sources.zip";>Download</a></p></td><td
 col
 span="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/apache-tapestry-5.3.8-sources.zip.asc";>ASC</a></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p>6de96428545fd235389c51d8e1d9008a</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Javadoc (zip)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/apache-tapestry-5.3.8-javadocs.zip";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/apache-tapestry-5.3.8-javadocs.zip.asc";>ASC</a></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p>f1ba1d4fa6fcbd10467aa5b803a5a001</p></td></tr></tbody></table></div></div><div
 class="columnMacro"><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="b
 order-bottom-width: 1px;"><b>Maven Dependency</b></div><div class="codeContent 
panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
   &lt;groupId&gt;org.apache.tapestry&lt;/groupId&gt;
   &lt;artifactId&gt;tapestry-core&lt;/artifactId&gt;
-  &lt;version&gt;5.3.7&lt;/version&gt;
+  &lt;version&gt;5.3.8&lt;/version&gt;
 &lt;/dependency&gt;
 ]]></script>
 </div></div></div></div></div></div><h2 id="Download-Tapestry5.2.x">Tapestry 
5.2.x</h2><p>Tapestry 5.2.6 was released 29 Jun 2011 and is expected to be the 
final release of the 5.2 branch. See the <a shape="rect" 
href="release-notes.html">release notes</a> for more details.</p><div 
class="sectionColumnWrapper"><div class="sectionMacro"><div 
class="sectionMacroRow"><div class="columnMacro"><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Tapestry 5.2.6</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Mirrors</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Checksum</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Signature</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Binary (tar.bz2)</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/tapestry-bin-5.2.6.tar.bz2";>D
 ownload</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a 
shape="rect" class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-bin-5.2.6.tar.bz2.md5";>MD5</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-bin-5.2.6.tar.bz2.asc";>ASC</a></p></td></tr><tr><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Binary (tar.gz)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/tapestry-bin-5.2.6.tar.gz";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-bin-5.2.6.tar.gz.md5";>MD5</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-bin-5.2.6.tar.gz.asc";>
 ASC</a></p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Binary (zip)</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/tapestry-bin-5.2.6.zip";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-bin-5.2.6.zip.md5";>MD5</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-bin-5.2.6.zip.asc";>ASC</a></p></td></tr><tr><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Source (tar.bz2)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/tapestry-src-5.2.6.tar.bz2";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" class="external
 -link" 
href="http://www.apache.org/dist/tapestry/tapestry-src-5.2.6.tar.bz2.md5";>MD5</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-src-5.2.6.tar.bz2.asc";>ASC</a></p></td></tr><tr><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Source (tar.gz)</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/tapestry-src-5.2.6.tar.gz";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-src-5.2.6.tar.gz.md5";>MD5</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-src-5.2.6.tar.gz.asc";>ASC</a></p></td></tr><tr><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Source (zip)</p></td><td c
 olspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dyn/closer.cgi/tapestry/tapestry-src-5.2.6.zip";>Download</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-src-5.2.6.zip.md5";>MD5</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" 
href="http://www.apache.org/dist/tapestry/tapestry-src-5.2.6.zip.asc";>ASC</a></p></td></tr></tbody></table></div></div><div
 class="columnMacro"><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>Maven Dependency</b></div><div class="codeContent panelContent pdl">

Modified: 
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.data/guess-1.png
==============================================================================
Binary files - no diff available.

Modified: 
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.html
==============================================================================
--- 
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.html 
(original)
+++ 
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.html 
Tue Nov 25 01:19:50 2014
@@ -76,14 +76,14 @@ table.ScrollbarTable td.ScrollbarNextIco
 
 /*]]>*/</style><div class="Scrollbar"><table class="ScrollbarTable"><tr><td 
colspan="1" rowspan="1" class="ScrollbarPrevIcon"><a shape="rect" 
href="exploring-the-project.html"><img align="middle" border="0" 
src="https://cwiki.apache.org/confluence/images/icons/back_16.gif"; width="16" 
height="16"></a></td><td colspan="1" rowspan="1" class="ScrollbarPrevName" 
width="33%"><a shape="rect" href="exploring-the-project.html">Exploring the 
Project</a>&#160;</td><td colspan="1" rowspan="1" class="ScrollbarParent" 
width="33%"><sup><a shape="rect" href="tapestry-tutorial.html"><img 
align="middle" border="0" 
src="https://cwiki.apache.org/confluence/images/icons/up_16.gif"; width="8" 
height="8"></a></sup><a shape="rect" href="tapestry-tutorial.html">Tapestry 
Tutorial</a></td><td colspan="1" rowspan="1" class="ScrollbarNextName" 
width="33%">&#160;<a shape="rect" 
href="using-beaneditform-to-create-user-forms.html">Using BeanEditForm To 
Create User Forms</a></td><td colspan="1" rowspan="1" class="Sc
 rollbarNextIcon"><a shape="rect" 
href="using-beaneditform-to-create-user-forms.html"><img align="middle" 
border="0" src="https://cwiki.apache.org/confluence/images/icons/forwd_16.gif"; 
width="16" height="16"></a></td></tr></table></div><p><span style="line-height: 
1.4285715;">Let's start building a basic Hi-Lo Guessing game.</span></p><p>In 
the game, the computer selects a number between 1 and 10. You try and guess the 
number, clicking links. At the end, the computer tells you how many guesses you 
required to identify the target number. Even a simple example like this will 
demonstrate several important concepts in Tapestry:</p><ul><li>Breaking an 
application into individual pages</li><li>Transferring information from one 
page to another</li><li>Responding to user interactions</li><li>Storing client 
information in the server-side session</li></ul><p>We'll build this little 
application in small pieces, using the kind of iterative development that 
Tapestry makes so easy.</p><p><img clas
 s="confluence-embedded-image" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/hilo-flow.png?version=2&amp;modificationDate=1286814202000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/hilo-flow.png?version=2&amp;modificationDate=1286814202000&amp;api=v2"></p><p>Our
 page flow is very simple, consisting of three pages: Index (the starting 
page), Guess and GameOver. The Index page introduces the application and 
includes a link to start guessing. The Guess page presents the user with ten 
links, plus feedback such as "too low" or "too high". The GameOver page tells 
the user how many guesses they took before finding the target number.</p><h1 
id="ImplementingtheHi-LoGuessingGame-IndexPage">Index Page</h1><p>Let's get to 
work on the Index page and template. Make Index.tml look like this:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Index.tml</b></div><div c
 lass="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; 
title=&quot;Hi/Lo Guess&quot;
-  xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;&gt;
+    xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;&gt;
 
-  &lt;p&gt;
-    I&#39;m thinking of a number between one and ten ... &lt;/p&gt;
-
-  &lt;p&gt;
-    &lt;a href=&quot;#&quot;&gt;start guessing&lt;/a&gt;
-  &lt;/p&gt;
+    &lt;p&gt;
+        I&#39;m thinking of a number between one and ten ...
+    &lt;/p&gt;
+    &lt;p&gt;
+        &lt;a href=&quot;#&quot;&gt;start guessing&lt;/a&gt;
+    &lt;/p&gt;
 
 &lt;/html&gt;
 ]]></script>
@@ -92,32 +92,32 @@ table.ScrollbarTable td.ScrollbarNextIco
 {
 }
 ]]></script>
-</div></div><p>Running the application gives us our start:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/hilo-1.png?version=2&amp;modificationDate=1416709010700&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/hilo-1.png?version=2&amp;modificationDate=1416709010700&amp;api=v2"></p><p>However,
 clicking the link doesn't do anything yet, as its just a placeholder &lt;a&gt; 
tag, not an actual Tapestry component. Let's think about what should happen 
when the user clicks that link:</p><ul><li>A random target number between 1 and 
10 should be selected</li><li>The number of guesses taken should be reset to 
0</li><li>The user should be sent to the Guess page to make a 
guess</li></ul><p>Our first step is to find out when the user clicks that 
"start guessing" link. In a typical web application framework, we might start 
thinking about URLs and handlers and maybe some sort of XML configuration 
 file. But this is Tapestry, so we're going to work with components and methods 
on our classes.</p><p>First, the component. We want to perform an action 
(selecting the number) before continuing on to the Guess page. The ActionLink 
component is just what we need; it creates a link with a URL that will trigger 
an action event in our code ... but that's getting ahead of ourselves. First 
up, convert the &lt;a&gt; tag to an ActionLink component:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Index.tml (partial)</b></div><div 
class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[  &lt;p&gt;
-    &lt;t:actionlink t:id=&quot;start&quot;&gt;start 
guessing&lt;/t:actionlink&gt;
-  &lt;/p&gt;
+</div></div><p>Running the application gives us our start:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/hilo-1.png?version=2&amp;modificationDate=1416709010000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/hilo-1.png?version=2&amp;modificationDate=1416709010000&amp;api=v2"></p><p>However,
 clicking the link doesn't do anything yet, as its just a placeholder &lt;a&gt; 
tag, not an actual Tapestry component. Let's think about what should happen 
when the user clicks that link:</p><ul><li>A random target number between 1 and 
10 should be selected</li><li>The number of guesses taken should be reset to 
0</li><li>The user should be sent to the Guess page to make a 
guess</li></ul><p>Our first step is to find out when the user clicks that 
"start guessing" link. In a typical web application framework, we might start 
thinking about URLs and handlers and maybe some sort of XML configuration 
 file. But this is Tapestry, so we're going to work with components and methods 
on our classes.</p><p>First, the component. We want to perform an action 
(selecting the number) before continuing on to the Guess page. The ActionLink 
component is just what we need; it creates a link with a URL that will trigger 
an action event in our code ... but that's getting ahead of ourselves. First 
up, convert the &lt;a&gt; tag to an ActionLink component:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Index.tml (partial)</b></div><div 
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[    &lt;p&gt;
+        &lt;t:actionlink t:id=&quot;start&quot;&gt;start 
guessing&lt;/t:actionlink&gt;
+    &lt;/p&gt;
 ]]></script>
-</div></div><p>If you refresh the browser and hover your mouse over the "start 
guessing" link, you'll see that its URL is now /tutorial1/index.start, which 
identifies the name of the page ("index") and the id of the component 
("start").</p><p>If you click the link now, you'll get an error:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/hilo-index-missing-action-error.png?version=3&amp;modificationDate=1416709525392&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/hilo-index-missing-action-error.png?version=3&amp;modificationDate=1416709525392&amp;api=v2"></p><p>Tapestry
 is telling us that we need to provide some kind of event handler for that 
event. What does that look like?</p><p>An event handler is a method of the Java 
class with a special name. The name is 
<code>on</code><strong><em>Eventname</em></strong><code>From</code><strong><em>Component-id</em></strong>
 ... here we want a 
 method named <code>onActionFromStart()</code>. How do we know that "action" is 
the right event name? Because that's what ActionLink does, that's why its named 
<strong><em>Action</em></strong>Link.</p><p>Once again, Tapestry gives us 
options; if you don't like naming conventions, there's an @<a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/OnEvent.html";>OnEvent</a>
 annotation you can place on the method instead, which restores the freedom to 
name the method as you like. Details about this approach are in the <a 
shape="rect" href="component-events.html">Tapestry Users' Guide</a>. We'll be 
sticking with the naming convention approach for the tutorial.</p><p>When 
handling a component event request (the kind of request triggered by the 
ActionLink component's URL), Tapestry will find the component and trigger a 
component event on it. This is the callback our server-side code needs to 
figure out what the user is doing o
 n the client side. Let's start with an empty event handler:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Index.java</b></div><div 
class="codeContent panelContent pdl">
+</div></div><p>If you refresh the browser and hover your mouse over the "start 
guessing" link, you'll see that its URL is now /tutorial1/index.start, which 
identifies the name of the page ("index") and the id of the component 
("start").</p><p>If you click the link now, you'll get an error:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/hilo-index-missing-action-error.png?version=3&amp;modificationDate=1416709525000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/hilo-index-missing-action-error.png?version=3&amp;modificationDate=1416709525000&amp;api=v2"></p><p>Tapestry
 is telling us that we need to provide some kind of event handler for that 
event. What does that look like?</p><p>An event handler is a method of the Java 
class with a special name. The name is 
<code>on</code><strong><em>Eventname</em></strong><code>From</code><strong><em>Component-id</em></strong>
 ... here we want a 
 method named <code>onActionFromStart()</code>. How do we know that "action" is 
the right event name? Because that's what ActionLink does, that's why its named 
<strong><em>Action</em></strong>Link.</p><p>Once again, Tapestry gives us 
options; if you don't like naming conventions, there's an @<a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/OnEvent.html";>OnEvent</a>
 annotation you can place on the method instead, which restores the freedom to 
name the method as you like. Details about this approach are in the <a 
shape="rect" href="component-events.html">Tapestry Users' Guide</a>. We'll be 
sticking with the naming convention approach for the tutorial.</p><p>When 
handling a component event request (the kind of request triggered by the 
ActionLink component's URL), Tapestry will find the component and trigger a 
component event on it. This is the callback our server-side code needs to 
figure out what the user is doing o
 n the client side. Let's start with an empty event handler:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Index.java</b></div><div 
class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[package com.example.tutorial.pages;
 
 public class Index
 {
-  void onActionFromStart()
-  {
+    void onActionFromStart()
+    {
 
-  }
+    }
 }
 ]]></script>
 </div></div><p>In the browser, we can re-try the failed component event 
request by hitting the refresh button ... or we can restart the application. In 
either case, we get the default behavior, which is simply to re-render the 
page.</p><p>Note that the event handler method does not have to be public; it 
can be protected, private, or package private (as in this example). By 
convention, such methods are package private, if for no other reason than it is 
the minimal amount of characters to type.</p><p>Hmm... right now you have to 
trust us that the method got invoked. That's no good ... what's a quick way to 
tell for sure? One way would be have the method throw an exception, but that's 
a bit ugly.</p><p>How about this: add the @<a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Log.html";>Log</a>
 annotation to the method:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" s
 tyle="border-bottom-width: 1px;"><b>Index.java (partial)</b></div><div 
class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[  import org.apache.tapestry5.annotations.Log;
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[import org.apache.tapestry5.annotations.Log;
 
-  . . .
+. . .
 
-  @Log
-  void onActionFromStart()
-  {
+    @Log
+    void onActionFromStart()
+    {
 
-  }
+    }
 ]]></script>
 </div></div><p>When you next click the link you should see the following in 
the Eclipse console:</p><div class="preformatted panel" style="border-width: 
1px;"><div class="preformattedContent panelContent">
 <pre>[DEBUG] pages.Index [ENTER] onActionFromStart()
@@ -130,12 +130,12 @@ public class Index
 
 public class Guess
 {
-  private int target;
+    private int target;
 
-  void setup(int target)
-  {
-    this.target = target;
-  }
+    void setup(int target)
+    {
+        this.target = target;
+    }
 }
 ]]></script>
 </div></div><p>Create that Guess.java file in the same folder as Index.java. 
Next, we can modify Index to invoke the <code>setup()</code> method of our new 
Guess page class:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>Index.java (revised)</b></div><div class="codeContent panelContent 
pdl">
@@ -148,20 +148,19 @@ import org.apache.tapestry5.annotations.
 
 public class Index
 {
-  private final Random random = new Random(System.nanoTime());
+    private final Random random = new Random(System.nanoTime());
 
-  @InjectPage
-  private Guess guess;
+    @InjectPage
+    private Guess guess;
 
-  @Log
-  Object onActionFromStart()
-  {
-    int target = random.nextInt(10) + 1;
-
-    guess.setup(target);
+    @Log
+    Object onActionFromStart()
+    {
+        int target = random.nextInt(10) + 1;
 
-    return guess;
-  }
+        guess.setup(target);
+        return guess;
+    }
 }
 ]]></script>
 </div></div><p>The new event handler method now chooses the target number, and 
tells the Guess page about it. Because Tapestry is a managed environment, we 
don't just create an instance of Guess ... it is Tapestry's responsibility to 
manage the life cycle of the Guess page. Instead, we ask Tapestry for the Guess 
page, using the @InjectPage annotation.</p>    <div class="aui-message warning 
shadowed information-macro">
@@ -176,49 +175,47 @@ public class Index
                             <p>When creating your own applications, make sure 
that the objects stored in final variables are thread safe. It seems 
counter-intuitive, but final variables are shared across many threads. Ordinary 
instance variables are not. Fortunately, the implementation of Random is, in 
fact, thread safe.</p>
                     </div>
     </div>
-<p>So ... let's click the link and see what we get:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-template-missing.png?version=2&amp;modificationDate=1416710821339&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-template-missing.png?version=2&amp;modificationDate=1416710821339&amp;api=v2"></p><p>Ah!
 We didn't create a Guess page template. Tapestry was really expecting us to 
create one, so we better do so.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 
1px;"><b>src/main/resources/com/example/tutorial/pages/Guess.tml</b></div><div 
class="codeContent panelContent pdl">
+<p>So ... let's click the link and see what we get:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-template-missing.png?version=2&amp;modificationDate=1416710821000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-template-missing.png?version=2&amp;modificationDate=1416710821000&amp;api=v2"></p><p>Ah!
 We didn't create a Guess page template. Tapestry was really expecting us to 
create one, so we better do so.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 
1px;"><b>src/main/resources/com/example/tutorial/pages/Guess.tml</b></div><div 
class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; 
title=&quot;Guess The Number&quot;
-  xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;&gt;
+    xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;&gt;
 
-  &lt;p&gt;
-  The secret number is: ${target}.
-  &lt;/p&gt;
+    &lt;p&gt;
+        The secret number is: ${target}.
+    &lt;/p&gt;
   
 &lt;/html&gt;
 ]]></script>
-</div></div><p>Hit the browser's back button, then click the "start guessing" 
link again. We're getting closer:</p><p><img class="confluence-embedded-image" 
width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-no-target-prop.png?version=2&amp;modificationDate=1416711075694&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-no-target-prop.png?version=2&amp;modificationDate=1416711075694&amp;api=v2"></p><p>If
 you scroll down, you'll see the line of the Guess.tml template that has the 
error. We have a field named target, but it is private and there's no 
corresponding property, so Tapestry was unable to access it.</p><p>We just need 
to write the missing JavaBeans accessor methods <code>getTarget()</code> (and 
<code>setTarget()</code> for good measure). Or we could let Tapestry write 
those methods instead:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[  @Property
-  private int target;
-]]></script>
-</div></div><p>The @<a shape="rect" class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Property.html";>Property</a>
 annotation very simply directs Tapestry to write the getter and setter method 
for you. You only need to do this if you are going to reference the field from 
the template.</p><p>We are getting very close but there's one last big oddity 
to handle. Once you refresh the page you'll see that target is 0!</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-target-zero.png?version=2&amp;modificationDate=1416711323804&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-target-zero.png?version=2&amp;modificationDate=1416711323804&amp;api=v2"></p><p>What
 gives? We know it was set to at least 1 ... where did the value go?</p><p>As 
noted above, Tapestry sends a redirect to the client after handling the event 
request. That mea
 ns that the rendering of the page happens in an entirely new request. 
Meanwhile, at the end of each request, Tapestry wipes out the value in each 
instance variable. So that means that target <em>was</em> a non-zero number 
during the component event request ... but by the time the new page render 
request comes up from the web browser to render the Guess page, the value of 
the target field has reverted back to its default, zero.</p><p>The solution 
here is to mark which fields have values that should persist from one request 
to the next (and next, and next ...). That's what the @<a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Persist.html";>Persist</a>
 annotation is for:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[  @Property  
-  @Persist
-  private int target;
+</div></div><p>Hit the browser's back button, then click the "start guessing" 
link again. We're getting closer:</p><p><img class="confluence-embedded-image" 
width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-no-target-prop.png?version=2&amp;modificationDate=1416711075000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-no-target-prop.png?version=2&amp;modificationDate=1416711075000&amp;api=v2"></p><p>If
 you scroll down, you'll see the line of the Guess.tml template that has the 
error. We have a field named target, but it is private and there's no 
corresponding property, so Tapestry was unable to access it.</p><p>We just need 
to write the missing JavaBeans accessor methods <code>getTarget()</code> (and 
<code>setTarget()</code> for good measure). Or we could let Tapestry write 
those methods instead:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[    @Property
+    private int target;
+]]></script>
+</div></div><p>The @<a shape="rect" class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Property.html";>Property</a>
 annotation very simply directs Tapestry to write the getter and setter method 
for you. You only need to do this if you are going to reference the field from 
the template.</p><p>We are getting very close but there's one last big oddity 
to handle. Once you refresh the page you'll see that target is 0!</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-target-zero.png?version=2&amp;modificationDate=1416711323000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-target-zero.png?version=2&amp;modificationDate=1416711323000&amp;api=v2"></p><p>What
 gives? We know it was set to at least 1 ... where did the value go?</p><p>As 
noted above, Tapestry sends a redirect to the client after handling the event 
request. That mea
 ns that the rendering of the page happens in an entirely new request. 
Meanwhile, at the end of each request, Tapestry wipes out the value in each 
instance variable. So that means that target <em>was</em> a non-zero number 
during the component event request ... but by the time the new page render 
request comes up from the web browser to render the Guess page, the value of 
the target field has reverted back to its default, zero.</p><p>The solution 
here is to mark which fields have values that should persist from one request 
to the next (and next, and next ...). That's what the @<a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Persist.html";>Persist</a>
 annotation is for:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[    @Property  
+    @Persist
+    private int target;
 ]]></script>
-</div></div><p>This doesn't have anything to do with database persistence 
(that's coming up in a later chapter). It means that the value is stored in the 
HttpSession between requests.</p><p>Go back to the Index page and click the 
link again. Finally, we have a target number:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-target.png?version=2&amp;modificationDate=1416711521970&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-target.png?version=2&amp;modificationDate=1416711521970&amp;api=v2"></p><p>That's
 enough for us to get started. Let's build out the Guess page, and get ready to 
let the user make guesses. We'll show the count of guesses, and increment that 
count when they make them. We'll worry about high and low and actually 
selecting the correct value later.</p><p>When building Tapestry pages, you 
sometimes start with the Java code and build the template to match, a
 nd sometime start with the template and build the Java code to match. Both 
approaches are valid. Here, lets start with the markup in the template, then 
figure out what we need in the Java code to make it work.</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Guess.tml (revised)</b></div><div 
class="codeContent panelContent pdl">
+</div></div><p>This doesn't have anything to do with database persistence 
(that's coming up in a later chapter). It means that the value is stored in the 
HttpSession between requests.</p><p>Go back to the Index page and click the 
link again. Finally, we have a target number:</p><p><img 
class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-target.png?version=2&amp;modificationDate=1416711521000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-target.png?version=2&amp;modificationDate=1416711521000&amp;api=v2"></p><p>That's
 enough for us to get started. Let's build out the Guess page, and get ready to 
let the user make guesses. We'll show the count of guesses, and increment that 
count when they make them. We'll worry about high and low and actually 
selecting the correct value later.</p><p>When building Tapestry pages, you 
sometimes start with the Java code and build the template to match, a
 nd sometime start with the template and build the Java code to match. Both 
approaches are valid. Here, lets start with the markup in the template, then 
figure out what we need in the Java code to make it work.</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Guess.tml (revised)</b></div><div 
class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; 
title=&quot;Guess The Number&quot;
-  xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;
-  xmlns:p=&quot;tapestry:parameter&quot;&gt;
-
-  &lt;p:sidebar&gt;
+    xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;
+    xmlns:p=&quot;tapestry:parameter&quot;&gt;
+ 
     &lt;p&gt;
-      The secret number is: ${target}.
-  &lt;/p&gt;
-  &lt;/p:sidebar&gt;
-
-  &lt;strong&gt;Guess number ${guessCount}&lt;/strong&gt;
-
-  &lt;p&gt;Make a guess from the options below:&lt;/p&gt;
-
-  &lt;ul&gt;
-    &lt;t:loop source=&quot;1..10&quot; value=&quot;current&quot;&gt;
-      &lt;li&gt;
-        &lt;t:actionlink t:id=&quot;makeGuess&quot; 
context=&quot;current&quot;&gt;${current}
-        &lt;/t:actionlink&gt;
-      &lt;/li&gt;
-    &lt;/t:loop&gt;
-  &lt;/ul&gt;
-
+        The secret number is: ${target}.
+    &lt;/p&gt;
+ 
+    &lt;strong&gt;Guess number ${guessCount}&lt;/strong&gt;
+ 
+    &lt;p&gt;Make a guess from the options below:&lt;/p&gt;
+ 
+    &lt;ul class=&quot;list-inline&quot;&gt;
+        &lt;t:loop source=&quot;1..10&quot; value=&quot;current&quot;&gt;
+            &lt;li&gt;
+            &lt;t:actionlink t:id=&quot;makeGuess&quot; 
context=&quot;current&quot;&gt;${current}
+            &lt;/t:actionlink&gt;
+            &lt;/li&gt;
+        &lt;/t:loop&gt;
+    &lt;/ul&gt;
+ 
 &lt;/html&gt;
 ]]></script>
 </div></div><p>So it looks like we need a <code>guessCount</code> property 
that starts at 1.</p><p>We're also seeing one new component, the Loop 
component. A Loop component iterates over the values passed to it in its 
<code>source</code> parameter, and renders it body once for each value. It 
updates the property bound to its <code>value</code> parameter before rendering 
its body.</p><p>That special property expression, <code>1..10</code>, generates 
a series of numbers from 1 to 10, inclusive. usually, when you use the Loop 
component, you are iterating over a List or Collection of values, such as the 
results of a database query.</p><p>So, the Loop component is going to set the 
<code>current</code> property to 1, and render its body (the \&lt;li\&gt; tag, 
and the ActionLink component). Then its going to set the <code>current</code> 
property to 2 and render its body again ... all the way up to 10.</p><p>And 
notice what we're doing with the ActionLink component; its no longer enough to 
 know the user clicked on the ActionLink ... we need to know <em>which 
iteration</em> the user clicked on. The <code>context</code> parameter allows a 
value to be added to the ActionLink's URL, and we can get it back in the event 
handler method.</p>    <div class="aui-message hint shadowed information-macro">
@@ -235,59 +232,59 @@ import org.apache.tapestry5.annotations.
 
 public class Guess
 {
-  @Property
-  @Persist
-  private int target, guessCount;
-
-  @Property
-  private int current;
-
-  void setup(int target)
-  {
-    this.target = target;
-    guessCount = 1;
-  }
-
-  void onActionFromMakeGuess(int value)
-  {
-    guessCount++;
-  }
+    @Property
+    @Persist
+    private int target, guessCount;
+
+    @Property
+    private int current;
+
+    void setup(int target)
+    {
+        this.target = target;
+        guessCount = 1;
+    }
+
+    void onActionFromMakeGuess(int value)
+    {
+        guessCount++;
+    }
 
 }
 ]]></script>
-</div></div><p>The revised version of Guess includes two new properties: 
<code>current</code> and <code>guessCount</code>. There's also a handler for 
the action event from the makeGuess ActionLink component; currently it just 
increments the count.</p><p>Notice that the 
<code>onActionFromMakeGuess()</code> method now has a parameter: the context 
value that was encoded into the URL by the ActionLink. When then user clicks 
the link, Tapestry will automatically extract the string from the URL, convert 
it to an int and pass that int value into the event handler method. More 
boilerplate code you don't have to write.</p><p>At this point, the page is 
partially operational:</p><p><img class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-1.png?version=1&amp;modificationDate=1290119564000&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-1.png?version=1&amp;modificationDate=1290119564000&amp;api=v2"
 ></p><p>Our next step is to actually check the value provided by the user 
 >against the target and provide feedback: either they guessed too high, or too 
 >low, or just right. If they get it just right, we'll switch to the GameOver 
 >page.</p><p>For wrong guesses, we'll see an update such as:</p><p><img 
 >class="confluence-embedded-image" width="700" 
 >src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess_feedback.png?version=1&amp;modificationDate=1291918635000&amp;api=v2";
 > 
 >data-image-src="/confluence/download/attachments/23340505/guess_feedback.png?version=1&amp;modificationDate=1291918635000&amp;api=v2"></p><p>And
 > correct guesses will send us to the GameOver page:</p><p><img 
 >class="confluence-embedded-image" width="700" 
 >src="https://cwiki.apache.org/confluence/download/attachments/23340505/gameover.png?version=1&amp;modificationDate=1291918700000&amp;api=v2";
 > 
 >data-image-src="/confluence/download/attachments/23340505/gameover.png?version=1&amp;modificationDate=129191870
 0000&amp;api=v2"></p><p>Let's start with the Guess page; it now needs a new 
property to store the message to be displayed to the user, and needs a field 
for the injected GameOver page:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Guess.java (partial)</b></div><div 
class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[  @Property
-  @Persist(PersistenceConstants.FLASH)
-  private String message;
+</div></div><p>The revised version of Guess includes two new properties: 
<code>current</code> and <code>guessCount</code>. There's also a handler for 
the action event from the makeGuess ActionLink component; currently it just 
increments the count.</p><p>Notice that the 
<code>onActionFromMakeGuess()</code> method now has a parameter: the context 
value that was encoded into the URL by the ActionLink. When then user clicks 
the link, Tapestry will automatically extract the string from the URL, convert 
it to an int and pass that int value into the event handler method. More 
boilerplate code you don't have to write.</p><p>At this point, the page is 
partially operational:</p><p><img class="confluence-embedded-image" width="700" 
src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess-1.png?version=3&amp;modificationDate=1416877818995&amp;api=v2";
 
data-image-src="/confluence/download/attachments/23340505/guess-1.png?version=3&amp;modificationDate=1416877818995&amp;api=v2"
 ></p><p>Our next step is to actually check the value provided by the user 
 >against the target and provide feedback: either they guessed too high, or too 
 >low, or just right. If they get it just right, we'll switch to the GameOver 
 >page.</p><p>For wrong guesses, we'll see an update such as:</p><p><img 
 >class="confluence-embedded-image" width="700" 
 >src="https://cwiki.apache.org/confluence/download/attachments/23340505/guess_feedback.png?version=1&amp;modificationDate=1291918635000&amp;api=v2";
 > 
 >data-image-src="/confluence/download/attachments/23340505/guess_feedback.png?version=1&amp;modificationDate=1291918635000&amp;api=v2"></p><p>And
 > correct guesses will send us to the GameOver page:</p><p><img 
 >class="confluence-embedded-image" width="700" 
 >src="https://cwiki.apache.org/confluence/download/attachments/23340505/gameover.png?version=1&amp;modificationDate=1291918700000&amp;api=v2";
 > 
 >data-image-src="/confluence/download/attachments/23340505/gameover.png?version=1&amp;modificationDate=129191870
 0000&amp;api=v2"></p><p>Let's start with the Guess page; it now needs a new 
property to store the message to be displayed to the user, and needs a field 
for the injected GameOver page:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Guess.java (partial)</b></div><div 
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[    @Property
+    @Persist(PersistenceConstants.FLASH)
+    private String message;
 
-  @InjectPage
-  private GameOver gameOver;
+    @InjectPage
+    private GameOver gameOver;
 ]]></script>
 </div></div><p>First off, we're seeing a variation of the @Persist annotation, 
where a persistence <em>strategy</em> is provided by name. <a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/PersistenceConstants.html#FLASH";>FLASH</a>
 is a built-in strategy that stores the value in the session, but only for one 
request ... it's designed specifically for these kind of feedback messages. If 
you hit F5 in the browser, to refresh, the page will render but the message 
will disappear.</p><p>Next, we need some more logic in the 
<code>onActionFromMakeGuess()</code> event handler method:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Guess.java (partial)</b></div><div 
class="codeContent panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[  Object onActionFromMakeGuess(int value)
-  {
-    if (value == target)
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[    Object onActionFromMakeGuess(int value)
     {
-      gameOver.setup(target, guessCount);
-      return gameOver;
-    }
+        if (value == target)
+        {
+            gameOver.setup(target, guessCount);
+            return gameOver;
+        }
 
-    guessCount++;
+        guessCount++;
 
-    message = String.format(&quot;Your guess of %d is too %s.&quot;, value,
-        value &lt; target ? &quot;low&quot; : &quot;high&quot;);
+        message = String.format(&quot;Your guess of %d is too %s.&quot;, value,
+            value &lt; target ? &quot;low&quot; : &quot;high&quot;);
 
-    return null;
-  }
+        return null;
+    }
 ]]></script>
 </div></div><p>Again, very straight-forward. If the value is correct, then we 
configure the GameOver page and return it, causing a redirect to that page. 
Otherwise, we increment the number of guesses, and format the message to 
display to the user.</p><p>In the template, we just need to add some markup to 
display the message:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>Guess.tml (partial)</b></div><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[  &lt;strong&gt;Guess number 
${guessCount}&lt;/strong&gt;
+<script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[    &lt;strong&gt;Guess number 
${guessCount}&lt;/strong&gt;
 
-  &lt;t:if test=&quot;message&quot;&gt;
-    &lt;p&gt;
-      &lt;strong&gt;${message}&lt;/strong&gt;
-    &lt;/p&gt;
-  &lt;/t:if&gt;
+    &lt;t:if test=&quot;message&quot;&gt;
+        &lt;p&gt;
+            &lt;strong&gt;${message}&lt;/strong&gt;
+        &lt;/p&gt;
+    &lt;/t:if&gt;
 ]]></script>
 </div></div><p>This snippet uses Tapestry's <a shape="rect" 
class="external-link" 
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/If.html";>If</a>
 component. The If component evaluates its <code>test</code> parameter and, if 
the value evaluates to true, renders its body. The property bound to 
<code>test</code> doesn't have to be a boolean; Tapestry treats 
<code>null</code> as false, it treats zero as false and non-zero as true, it 
treats an empty Collection as false ... and for Strings (such as 
<code>message</code>) it treats a blank string (one that is null, or consists 
only of whitespace) as false, and a non-blank string is true.</p><p>We can wrap 
up with the GameOver page:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>GameOver.java</b></div><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[package com.example.tutorial.pages;
@@ -297,29 +294,29 @@ import org.apache.tapestry5.annotations.
 
 public class GameOver
 {
-  @Property
-  @Persist
-  private int target, guessCount;
-
-  void setup(int target, int guessCount)
-  {
-    this.target = target;
-    this.guessCount = guessCount;
-  }
+    @Property
+    @Persist
+    private int target, guessCount;
+
+    void setup(int target, int guessCount)
+    {
+        this.target = target;
+        this.guessCount = guessCount;
+    }
 }
 ]]></script>
 </div></div><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>GameOver.tml</b></div><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[&lt;html t:type=&quot;layout&quot; 
title=&quot;Game Over&quot;
-  xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;
-  xmlns:p=&quot;tapestry:parameter&quot;&gt;
+    xmlns:t=&quot;http://tapestry.apache.org/schema/tapestry_5_3.xsd&quot;
+    xmlns:p=&quot;tapestry:parameter&quot;&gt;
 
-  &lt;p&gt;
-    You guessed the number
-    &lt;strong&gt;${target}&lt;/strong&gt;
-    in
-    &lt;strong&gt;${guessCount}&lt;/strong&gt;
-    guesses.
-  &lt;/p&gt;
+    &lt;p&gt;
+        You guessed the number
+        &lt;strong&gt;${target}&lt;/strong&gt;
+        in
+        &lt;strong&gt;${guessCount}&lt;/strong&gt;
+        guesses.
+    &lt;/p&gt;
   
 &lt;/html&gt;
 ]]></script>


Reply via email to