Author: buildbot
Date: Sun Aug 9 16:20:08 2015
New Revision: 961249
Log:
Production update by buildbot for tapestry
Modified:
websites/production/tapestry/content/aliases.html
websites/production/tapestry/content/cache/main.pageCache
websites/production/tapestry/content/creating-the-skeleton-application.html
websites/production/tapestry/content/exploring-the-project.html
websites/production/tapestry/content/implementing-the-hi-lo-guessing-game.html
websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html
websites/production/tapestry/content/using-tapestry-with-hibernate.html
Modified: websites/production/tapestry/content/aliases.html
==============================================================================
--- websites/production/tapestry/content/aliases.html (original)
+++ websites/production/tapestry/content/aliases.html Sun Aug 9 16:20:08 2015
@@ -136,7 +136,7 @@
</div>
</li></ul>
-</div><p> </p><p>See <a shape="rect"
href="ioc-cookbook-overriding-ioc-services.html">IoC Cookbook - Overriding IoC
Services</a></p><h1 id="Aliases-Introduction">Introduction</h1><p>Tapestry goes
to great lengths so that you can use the [Inject|#inject.html] annotation on a
field and provide no additional data, yet end up with the correct object or
service.</p><p>In many cases, Tapestry must match a field type to an available
IoC service.</p><p>If there is only single service in the registry that
implements the service, Tapestry will utilize that service.</p><p>When there is
more than one such service, it is necessary to disambiguate which service is to
be injected. To disambiguate globally (across all injections), you must create
an alias from the service interface directly to the particular
service.</p><p>This takes the form of a contribution to the Alias
service.</p><p>The Alias service has additional purposes: first, it allows for
spot overrides on injected services, based
on the application's mode. Currently, the only mode is "servlet", but future
modes may include "portlet" and possibly "offline".</p><p>Secondly, the
companion AliasOverrides service configuration allows for spot overrides of
specific services, without disturbing the rest of the network of services
within the IoC Registry.</p><h1 id="Aliases-ContributinganAlias">Contributing
an Alias</h1><p>To contribute a new service to the Alias service, you must
first decide on a logical name. Often, this is the name of the service
interface implemented by the service.</p><p>You can then contribute into the
Infrastructure service's configuration:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div><p> </p><p>See <a shape="rect"
href="ioc-cookbook-overriding-ioc-services.html">IoC Cookbook - Overriding IoC
Services</a></p><h1 id="Aliases-Introduction">Introduction</h1><p>Tapestry goes
to great lengths so that you can use the <a shape="rect"
href="injection.html">Inject</a> annotation on a field and provide no
additional data, yet end up with the correct object or service.</p><p>In many
cases, Tapestry must match a field type to an available IoC service.</p><p>If
there is only single service in the registry that implements the service,
Tapestry will utilize that service.</p><p>When there is more than one such
service, it is necessary to disambiguate which service is to be injected. To
disambiguate globally (across all injections), you must create an alias from
the service interface directly to the particular service.</p><p>This takes the
form of a contribution to the Alias service.</p><p>The Alias service has
additional purposes: first, it allows for spot overrides o
n injected services, based on the application's mode. Currently, the only mode
is "servlet", but future modes may include "portlet" and possibly
"offline".</p><p>Secondly, the companion AliasOverrides service configuration
allows for spot overrides of specific services, without disturbing the rest of
the network of services within the IoC Registry.</p><h1
id="Aliases-ContributinganAlias">Contributing an Alias</h1><p>To contribute a
new service to the Alias service, you must first decide on a logical name.
Often, this is the name of the service interface implemented by the
service.</p><p>You can then contribute into the Infrastructure service's
configuration:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public static void
contributeAlias(@InjectService("MyService") MyService myService,
Configuration<AliasContribution> configuration)
{
Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified:
websites/production/tapestry/content/creating-the-skeleton-application.html
==============================================================================
--- websites/production/tapestry/content/creating-the-skeleton-application.html
(original)
+++ websites/production/tapestry/content/creating-the-skeleton-application.html
Sun Aug 9 16:20:08 2015
@@ -81,7 +81,7 @@
<localRepository>C:/Users/joeuser/.m2/repository</localRepository>
</settings>
</pre>
-</div></div><p>Of course, adjust the <code>localRepository</code> element to
match the correct path for your computer.</p></div></div><p>Okay, let's get
started creating our new project.</p><p>In Eclipse, go to <strong>File > New
></strong> <strong>Project... > Maven > Maven
Project</strong></p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/select-a-wizard.png"></span></p><p>Then
click <strong>Next</strong>, <strong>Next</strong> (again), and then on the
<strong>Select an Archetype</strong> page click the <strong>Configure</strong>
button on the Catalog line. The <strong>Archetype</strong> preferences dialog
should appear. Click the <strong>Add Remote Catalog...</strong> button, as
shown below:</p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/add-archetype-catalog.png"></span></p><p>As
shown above, en
ter <span class="nolink"><span
class="nolink">"http://tapestry.apache.org"</span></span> in the Catalog File
field, and "Apache Tapestry" in the Description field.</p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>If you want to try an unreleased
(alpha or beta) version of Tapestry, use <span class="nolink">the
<strong>https://repository.apache.org/content/repositories/staging</strong></span>
archetype catalog file instead.</p></div></div><p>Click <strong>OK</strong>,
then<strong> OK</strong> again.</p><p>On the Select an Archetype dialog (shown
below), select the newly-added Apache Tapestry catalog, then select the
"quickstart" artifact from the list and click
<strong>Next</strong>.</p><p><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image"
src="creating-the-skeleton-ap
plication.data/select-archetype.png"></span></p><p><em><strong>Note:</strong>
Screenshots in this tutorial may show different (either newer or older)
versions of Tapestry than you may see.</em></p><p>Fill in the Group Id,
Artifact Id, Version and Package  as follows:</p><p><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image"
src="creating-the-skeleton-application.data/specify-archetype-parameters.png"></span></p><p>then
click Finish.</p><div class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The first time you use Maven,
project creation may take a while as Maven downloads a large number of JAR
dependencies for Maven, Jetty and Tapestry. These downloaded files are cached
locally and will not need to be downloaded again, but you do have to be patient
on first use.</p></div></
div><p>After Maven finishes, you'll see a new directory, <code>tutorial in
your Package Explorer view in Eclipse.</code></p><h2
id="CreatingTheSkeletonApplication-RunningtheApplicationusingJetty">Running the
Application using Jetty</h2><p>One of the first things you can do is use Maven
to run Jetty directly.</p><p>Right-click on the tutorial project in your
Package Explorer view and select <strong>Run As > Maven Build...
></strong>, enter a Goal of <strong>"jetty:run"</strong>. This creates a
"Run Configuration" named "tutorial1" that we'll use throughout this tutorial
to start the app:</p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/run-configuration.png"></span></p><p>Tapestry
runs best with a couple of additional options; click the "JRE" tab and enter
the following VM
Arguments:</p><pre></pre><p>-XX:MaxPermSize=256M</p><p>-Xmx600m</p><p>-Dtapestry.execution-mode=development</p><p><code><
em>(If you're using JDK 1.8 then you should omit the MaxPermSize
argument.)</em></code></p><p><code>Here's how it looks:<br
clear="none"></code></p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/run-configuration-jre.png"></span></p><p>Finally,
click <strong>Run</strong>.</p><p>Again, the first time, there's a dizzying
number of downloads, but before you know it, the Jetty servlet container is up
and running.</p><p>Once Jetty is initialized (which only takes a few seconds
after the first time), you'll see the following in your console:</p><p><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image"
src="creating-the-skeleton-application.data/console-startup.png"></span></p><p><em>Note
the red square icon above. Later on you'll use that icon to stop Jetty before
restarting the app.</em></p><p>You can now open a web browser to <a
shape="rect" class="external-link" href="ht
tp://localhost:8080/tutorial1/" >http://localhost:8080/tutorial1/</a> to see
the running application:</p><p> </p><p><span
class="confluence-embedded-file-wrapper image-left-wrapper"><img
class="confluence-embedded-image confluence-content-image-border image-left"
src="creating-the-skeleton-application.data/startpage.png"></span></p><p> </p><div
style="clear: both"></div><p style="text-align: left;">The date and time in
the middle of the page shows that this is a live application.</p><p>This is a
complete little web app; it doesn't do much, but it demonstrate how to create a
number of pages sharing a common layout, and demonstrates some simple
navigation and link handling. You can see that it has several different pages
that share a common layout. (<span style="line-height:
1.4285715;"><em>Layout</em> is a loose term meaning common look and feel and
navigation across many or all of the pages of an application. Often an
application will include a Layout component to provide
that commonness.)</span></p><p><span style="line-height: 1.4285715;">Next: <a
shape="rect" href="exploring-the-project.html">Exploring the
Project</a></span></p><p><span style="line-height: 1.4285715;"><br
clear="none"></span></p></div>
+</div></div><p>Of course, adjust the <code>localRepository</code> element to
match the correct path for your computer.</p></div></div><p>Okay, let's get
started creating our new project.</p><p>In Eclipse, go to <strong>File > New
></strong> <strong>Project... > Maven > Maven
Project</strong></p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/select-a-wizard.png"></span></p><p>Then
click <strong>Next</strong>, <strong>Next</strong> (again), and then on the
<strong>Select an Archetype</strong> page click the <strong>Configure</strong>
button on the Catalog line. The <strong>Archetype</strong> preferences dialog
should appear. Click the <strong>Add Remote Catalog...</strong> button, as
shown below:</p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/add-archetype-catalog.png"></span></p><p>As
shown above, en
ter <span class="nolink"><span
class="nolink">"http://tapestry.apache.org"</span></span> in the Catalog File
field, and "Apache Tapestry" in the Description field.</p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>If you want to try an unreleased
(alpha or beta) version of Tapestry, use <span class="nolink">the
<strong>https://repository.apache.org/content/repositories/staging</strong></span>
archetype catalog file instead.</p></div></div><p>Click <strong>OK</strong>,
then<strong> OK</strong> again.</p><p>On the Select an Archetype dialog (shown
below), select the newly-added Apache Tapestry catalog, then select the
"quickstart" artifact from the list and click
<strong>Next</strong>.</p><p><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image"
src="creating-the-skeleton-ap
plication.data/select-archetype.png"></span></p><p><em><strong>Note:</strong>
Screenshots in this tutorial may show different (either newer or older)
versions of Tapestry than you may see.</em></p><p>Fill in the Group Id,
Artifact Id, Version and Package  as follows:</p><p><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image"
src="creating-the-skeleton-application.data/specify-archetype-parameters.png"></span></p><p>then
click Finish.</p><div class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The first time you use Maven,
project creation may take a while as Maven downloads a large number of JAR
dependencies for Maven, Jetty and Tapestry. These downloaded files are cached
locally and will not need to be downloaded again, but you do have to be patient
on first use.</p></div></
div><p>After Maven finishes, you'll see a new directory, <code>tutorial1, in
your Package Explorer view in Eclipse.</code></p><h2
id="CreatingTheSkeletonApplication-RunningtheApplicationusingJetty">Running the
Application using Jetty</h2><p>One of the first things you can do is use Maven
to run Jetty directly.</p><p>Right-click on the <code>tutorial1</code> project
in your Package Explorer view and select <strong>Run As > Maven Build...
></strong>, enter a Goal of <strong>"jetty:run"</strong>. This creates a
"Run Configuration" named "tutorial1" that we'll use throughout this tutorial
to start the app:</p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/run-configuration.png"></span></p><p>Tapestry
runs best with a couple of additional options; click the "JRE" tab and enter
the following VM
Arguments:</p><pre></pre><p>-XX:MaxPermSize=256M</p><p>-Xmx600m</p><p>-Dtapestry.execution-mode=developme
nt</p><p><code><em>(If you're using JDK 1.8 then you should omit the
MaxPermSize argument.)</em></code></p><p><code>Here's how it looks:<br
clear="none"></code></p><p><span class="confluence-embedded-file-wrapper"><img
class="confluence-embedded-image"
src="creating-the-skeleton-application.data/run-configuration-jre.png"></span></p><p>Finally,
click <strong>Run</strong>.</p><p>Again, the first time, there's a dizzying
number of downloads, but before you know it, the Jetty servlet container is up
and running.</p><p>Once Jetty is initialized (which only takes a few seconds
after the first time), you'll see the following in your console:</p><p><span
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image"
src="creating-the-skeleton-application.data/console-startup.png"></span></p><p><em>Note
the red square icon above. Later on you'll use that icon to stop Jetty before
restarting the app.</em></p><p>You can now open a web browser to <a
shape="rect" class="externa
l-link" href="http://localhost:8080/tutorial1/"
>http://localhost:8080/tutorial1/</a> to see the running
application:</p><p> </p><p><span class="confluence-embedded-file-wrapper
image-left-wrapper"><img class="confluence-embedded-image
confluence-content-image-border image-left"
src="creating-the-skeleton-application.data/startpage.png"></span></p><p> </p><div
style="clear: both"></div><p style="text-align: left;">The date and time in
the middle of the page shows that this is a live application.</p><p>This is a
complete little web app; it doesn't do much, but it demonstrate how to create a
number of pages sharing a common layout, and demonstrates some simple
navigation and link handling. You can see that it has several different pages
that share a common layout. (<span style="line-height:
1.4285715;"><em>Layout</em> is a loose term meaning common look and feel and
navigation across many or all of the pages of an application. Often an
application will include a Layout compo
nent to provide that commonness.)</span></p><p><span style="line-height:
1.4285715;">Next: <a shape="rect" href="exploring-the-project.html">Exploring
the Project</a></span></p><p><span style="line-height: 1.4285715;"><br
clear="none"></span></p></div>
</div>
<div class="clearer"></div>
Modified: websites/production/tapestry/content/exploring-the-project.html
==============================================================================
--- websites/production/tapestry/content/exploring-the-project.html (original)
+++ websites/production/tapestry/content/exploring-the-project.html Sun Aug 9
16:20:08 2015
@@ -78,7 +78,7 @@
<!-- The only significant configuration for Tapestry 5, this
informs Tapestry
of where to look for pages, components and mixins. -->
<param-name>tapestry.app-package</param-name>
- <param-value>com.example.tutorial</param-value>
+ <param-value>com.example.tutorial1</param-value>
</context-param>
<!--
Specify some additional Modules for two different execution
@@ -88,13 +88,13 @@ of where to look for pages, components a
<context-param>
<param-name>tapestry.development-modules</param-name>
<param-value>
- com.example.tutorial.services.DevelopmentModule
+ com.example.tutorial1.services.DevelopmentModule
</param-value>
</context-param>
<context-param>
<param-name>tapestry.qa-modules</param-name>
<param-value>
- com.example.tutorial.services.QaModule
+ com.example.tutorial1.services.QaModule
</param-value>
</context-param>
<filter>
@@ -107,8 +107,8 @@ of where to look for pages, components a
</filter-mapping>
</web-app>
</pre>
-</div></div><p>This is short and sweet: you can see that the package name you
provided earlier shows up as the <code>tapestry.app-package</code> context
parameter; the TapestryFilter instance will use this information to locate the
Java classes for pages and components.</p><p>Tapestry operates as a <em>servlet
filter</em> rather than as a traditional <em>servlet</em>. In this way,
Tapestry has a chance to intercept all incoming requests, to determine which
ones apply to Tapestry pages (or other resources). The net effect is that you
don't have to maintain any additional configuration for Tapestry to operate,
regardless of how many pages or components you add to your
application.</p><p>Much of the rest of web.xml is configuration to match
Tapestry execution modes against module classes. An execution mode defines how
the application is being run: the default execution mode is "production", but
the web.xml defines two additional modes: "development" and "qa" (for "Quality
Assurance").
The module classes indicated will be loaded for those execution modes, and can
change the configuration of the application is various ways. We'll come back to
execution modes and module classes later in the tutorial.</p><p>Tapestry pages
minimally consist of an ordinary Java class plus a component template
file.</p><p>In the root of your web application, a page named "Index" will be
used for any request that specifies no additional path after the context
name.</p><h1 id="ExploringtheProject-IndexJavaClass">Index Java
Class</h1><p>Tapestry has very specific rules for where page classes go.
Tapestry adds a sub-package, "pages", to the root application package
("com.example.tutorial"); the Java classes for pages goes there. Thus the full
Java class name is com.example.tutorial.pages.Index.</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/pages/Index.java</b></div><di
v class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+</div></div><p>This is short and sweet: you can see that the package name you
provided earlier shows up as the <code>tapestry.app-package</code> context
parameter; the TapestryFilter instance will use this information to locate the
Java classes for pages and components.</p><p>Tapestry operates as a <em>servlet
filter</em> rather than as a traditional <em>servlet</em>. In this way,
Tapestry has a chance to intercept all incoming requests, to determine which
ones apply to Tapestry pages (or other resources). The net effect is that you
don't have to maintain any additional configuration for Tapestry to operate,
regardless of how many pages or components you add to your
application.</p><p>Much of the rest of web.xml is configuration to match
Tapestry execution modes against module classes. An execution mode defines how
the application is being run: the default execution mode is "production", but
the web.xml defines two additional modes: "development" and "qa" (for "Quality
Assurance").
The module classes indicated will be loaded for those execution modes, and can
change the configuration of the application is various ways. We'll come back to
execution modes and module classes later in the tutorial.</p><p>Tapestry pages
minimally consist of an ordinary Java class plus a component template
file.</p><p>In the root of your web application, a page named "Index" will be
used for any request that specifies no additional path after the context
name.</p><h1 id="ExploringtheProject-IndexJavaClass">Index Java
Class</h1><p>Tapestry has very specific rules for where page classes go.
Tapestry adds a sub-package, "pages", to the root application package
("com.example.tutorial1"); the Java classes for pages goes there. Thus the full
Java class name is
<code>com.example.</code>tutorial<code>1.pages.Index</code>.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/p
ages/Index.java</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
import java.util.Date;
import org.apache.tapestry5.annotations.*;
@@ -233,13 +233,13 @@ public class Index
-<span class="gliffy-container" id="gliffy-container-24346949-9971"
data-fullwidth="913" data-ceoid="24188263"
data-edit="${diagramEditLink.getLinkUrl()}"
data-full="${diagramZoomLink.getLinkUrl()}" data-filename="Templates and
Parameters">
+<span class="gliffy-container" id="gliffy-container-24346949-9182"
data-fullwidth="913" data-ceoid="24188263"
data-edit="${diagramEditLink.getLinkUrl()}"
data-full="${diagramZoomLink.getLinkUrl()}" data-filename="Templates and
Parameters">
- <map id="gliffy-map-24346949-3231" name="gliffy-map-24346949-3231"></map>
+ <map id="gliffy-map-24346949-4085" name="gliffy-map-24346949-4085"></map>
- <img class="gliffy-image gliffy-image-border"
id="gliffy-image-24346949-9971" width="304" height="300" data-full-width="913"
data-full-height="901"
src="https://cwiki.apache.org/confluence/download/attachments/24188263/Templates%20and%20Parameters.png?version=2&modificationDate=1371888025000&api=v2"
alt="Templates and Parameters" usemap="#gliffy-map-24346949-3231">
+ <img class="gliffy-image gliffy-image-border"
id="gliffy-image-24346949-9182" width="304" height="300" data-full-width="913"
data-full-height="901"
src="https://cwiki.apache.org/confluence/download/attachments/24188263/Templates%20and%20Parameters.png?version=2&modificationDate=1371888025000&api=v2"
alt="Templates and Parameters" usemap="#gliffy-map-24346949-4085">
- <map class="gliffy-dynamic" id="gliffy-dynamic-map-24346949-9971"
name="gliffy-dynamic-map-24346949-9971"></map>
+ <map class="gliffy-dynamic" id="gliffy-dynamic-map-24346949-9182"
name="gliffy-dynamic-map-24346949-9182"></map>
</span>
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
Sun Aug 9 16:20:08 2015
@@ -79,8 +79,10 @@
</html>
</pre>
-</div></div><p>And edit the corresponding Java class, Index.java, removing its
body (but leaving the imports in place for now):</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">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">public class Index
+</div></div><p>And edit the corresponding Java class, Index.java, removing its
body (but you can leave the imports in place for now):</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">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
+
+public class Index
{
}
</pre>
@@ -90,7 +92,7 @@
</p>
</pre>
</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><span
class="confluence-embedded-file-wrapper image-center-wrapper
confluence-embedded-manual-size"><img class="confluence-embedded-image
image-center" width="500"
src="implementing-the-hi-lo-guessing-game.data/Application_Exception.png"></span></p><p> </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 on the client side. Let's start with an empty
event handler:</p><div class="code panel pdl" style="border-wid
th: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>Index.java</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
public class Index
{
@@ -118,7 +120,7 @@ public class Index
[INFO] AppModule.TimingFilter Request time: 5 ms
</pre>
</div></div><p>The @Log annotation directs Tapestry to log method entry and
exit. You'll get to see any parameters passed into the method, and any return
value from the method ... as well as any exception thrown from within the
method. It's a powerful debugging tool. This is an example of Tapestry's
meta-programming power, something we'll use quite a bit of in the
tutorial.</p><p>Why do we see two requests for one click? Tapestry uses an
approach based on the <a shape="rect" class="external-link"
href="http://en.wikipedia.org/wiki/Post/Redirect/Get" >Post/Redirect/Get</a>
pattern. In fact, Tapestry generally performs a redirect after each component
event. So the first request was to process the action, and the second request
was to re-render the Index page. You can see this in the browser, because the
URL is still "/tutorial1" (the URL for rendering the Index page). We'll return
to this in a bit.</p><p>We're ready for the next step, which involves tying
together the Index and Guess
pages. Index will select a target number for the user to Guess, then "pass the
baton" to the Guess page.</p><p>Let's start by thinking about the Guess page.
It needs a variable to store the target value in, and it needs a method that
the Index page can invoke, to set up that target value.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Guess.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
public class Guess
{
@@ -131,7 +133,7 @@ public class Guess
}
</pre>
</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">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
import java.util.Random;
@@ -199,7 +201,7 @@ public class Index
</html>
</pre>
</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 \<li\> 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="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The URL for the ActionLink will be
<code>/tutorial1/guess.makeguess/3</code>. That's the page name, "Guess", the
component id, "makeGuess", and the context value, "3".</p></div></div><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Guess.java
(revised)</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
@@ -261,7 +263,7 @@ public class Guess
</t:if>
</pre>
</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 white space) 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">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
Modified:
websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html
==============================================================================
---
websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html
(original)
+++
websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html
Sun Aug 9 16:20:08 2015
@@ -67,9 +67,9 @@
<div id="content">
<div id="ConfluenceContent"><p>In the previous chapters, we saw how Tapestry
can handle simple links, even links that pass information in the URL. In this
chapter, we'll see how Tapestry can do the same, and quite a bit more, for HTML
forms.</p><p>Form support in Tapestry is deep and rich, more than can be
covered in a single chapter. However, we can show the basics, including some
very common development patterns. To get started, let's create a simple address
book application.</p><p>We'll start with the entity data, a simple object to
store the information we'll need. These classes go in an <code>entities</code>
sub-package. Unlike the use of the <code>pages</code> sub-package (for page
component classes), this is not enforced by Tapestry; it's just a convention
(but as we'll see shortly, a handy one).</p><p>Tapestry treats public fields as
if they were JavaBeans properties; since the Address object is just "dumb
data", there's no need to get carried away writing getters and setter
s. Instead, we'll define an entity that is all public fields:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/entities/Address.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.entities;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.entities;
-import com.example.tutorial.data.Honorific;
+import com.example.tutorial1.data.Honorific;
public class Address
{
@@ -86,7 +86,7 @@ public class Address
}
</pre>
</div></div><p>We also need to define the enum type, Honorific:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/data/Honorific.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.data;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.data;
public enum Honorific
{
@@ -109,30 +109,30 @@ public enum Honorific
</html>
</pre>
</div></div><p>(Note: for Tapestry 5.4, make that
<code>tapestry_5_4.xsd</code> instead.)</p><p>Next, the corresponding
class:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/pages/address/CreateAddress.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages.address;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages.address;
public class CreateAddress
{
}
</pre>
-</div></div><p>So ... why is the class named "CreateAddress" and not simply
"Create"? Actually, we could have named it "Create", and the application would
still work, but the longer <em>class</em> name is equally valid. Tapestry
noticed the redundancy in the class name
(com.example.tutorial.pages.<code><em>address</em></code>.Create<em>Address</em>)
and just stripped out the redundant suffix.</p><p><span style="line-height:
1.4285715;">Tapestry actually creates a bunch of aliases for you pages; any of
these aliases are valid and can appear in URLs or in the page parameter of
PageLink.  You can see the list in the console:</span></p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>So ... why is the class named "CreateAddress" and not simply
"Create"? Actually, we could have named it "Create", and the application would
still work, but the longer <em>class</em> name is equally valid. Tapestry
noticed the redundancy in the class name
(com.example.tutorial1.pages.<code><em>address</em></code>.Create<em>Address</em>)
and just stripped out the redundant suffix.</p><p><span style="line-height:
1.4285715;">Tapestry actually creates a bunch of aliases for you pages; any of
these aliases are valid and can appear in URLs or in the page parameter of
PageLink.  You can see the list in the console:</span></p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">[INFO] TapestryModule.ComponentClassResolver Available
pages (12):
- (blank): com.example.tutorial.pages.Index
+ (blank): com.example.tutorial1.pages.Index
ComponentLibraries: org.apache.tapestry5.corelib.pages.ComponentLibraries
- Error404: com.example.tutorial.pages.Error404
+ Error404: com.example.tutorial1.pages.Error404
ExceptionReport: org.apache.tapestry5.corelib.pages.ExceptionReport
- GameOver: com.example.tutorial.pages.GameOver
- Guess: com.example.tutorial.pages.Guess
- Index: com.example.tutorial.pages.Index
+ GameOver: com.example.tutorial1.pages.GameOver
+ Guess: com.example.tutorial1.pages.Guess
+ Index: com.example.tutorial1.pages.Index
PageCatalog: org.apache.tapestry5.corelib.pages.PageCatalog
PropertyDisplayBlocks: org.apache.tapestry5.corelib.pages.PropertyDisplayBlocks
PropertyEditBlocks: org.apache.tapestry5.corelib.pages.PropertyEditBlocks
ServiceStatus: org.apache.tapestry5.corelib.pages.ServiceStatus
T5Dashboard: org.apache.tapestry5.corelib.pages.T5Dashboard
- address/Create: com.example.tutorial.pages.address.CreateAddress
-address/CreateAddress: com.example.tutorial.pages.address.CreateAddress</pre>
-</div></div><p><span style="line-height: 1.4285715;">Tapestry users the
shortest alias when constructing URLs.</span></p><p><span style="line-height:
1.4285715;">Eventually, your application will probably have more entities:
perhaps you'll have a "user/Create" page and a "payment/Create" page and an
"account/Create" page. You </span><em style="line-height:
1.4285715;">could</em><span style="line-height: 1.4285715;"> have a bunch of
different classes all named Create spread across a number of different
packages. That's legal Java, but it isn't ideal. You may find yourself
accidentally editing the Java code for creating an Account when you really want
to be editing the code for creating a Payment.</span></p><p>Tapestry is
encouraging you to use a more descriptive name: Create<em>Address</em>, not
just Create, but it isn't making you pay the cost (in terms of longer, uglier
URLs). The URL to access the page will still be <a shape="rect"
class="external-link" href="http://localhost:8080
/tutorial1/address/create"
>http://localhost:8080/tutorial1/address/create</a>.</p><p>And remember,
regardless of the name that Tapestry assigns to your page, the template file is
named like the Java class itself: CreateAddress.tml.</p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Index pages work in folders as
well. A class named com.example.tutorial.pages.address.AddressIndex would be
given the name "address/Index". However, Tapestry has special rules for pages
named "Index" and the rendered URL would be <a shape="rect"
class="external-link" href="http://localhost:8080/tutorial1/address/"
>http://localhost:8080/tutorial1/address/</a>. In other words, you can place
Index pages in any folder and Tapestry will build a short URL for that page ...
and you <em>don't</em> have to keep naming the classes Ind
ex (it's confusing to have many classes with the same name, even across
multiple packages); instead, you can name each index page after the package
that contains it. Tapestry users a smart <em>convention</em> to keep it all
straight and generate short, to the point URLs.</p></div></div><h1
id="UsingBeanEditFormToCreateUserForms-UsingtheBeanEditFormComponent">Using the
BeanEditForm Component</h1><p>Time to start putting together the logic for this
form. Tapestry has a specific component for client-side Forms: the <a
shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Form.html">Form</a>
component, as well as components for form controls, such as <a shape="rect"
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Checkbox.html">Checkbox</a>
and <a shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corel
ib/components/TextField.html">TextField</a>. We'll cover those in a bit more
detail later .. instead, we're again going to let Tapestry do the heavy lifting
for us, via the <a shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/BeanEditForm.html">BeanEditForm</a>
component.</p><p>Add the following to the CreateAddress template (replacing
the "coming soon ..." message):</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>CreateAddress.tml (partial)</b></div><div
class="codeContent panelContent pdl">
+ address/Create: com.example.tutorial1.pages.address.CreateAddress
+address/CreateAddress: com.example.tutorial1.pages.address.CreateAddress</pre>
+</div></div><p><span style="line-height: 1.4285715;">Tapestry users the
shortest alias when constructing URLs.</span></p><p><span style="line-height:
1.4285715;">Eventually, your application will probably have more entities:
perhaps you'll have a "user/Create" page and a "payment/Create" page and an
"account/Create" page. You </span><em style="line-height:
1.4285715;">could</em><span style="line-height: 1.4285715;"> have a bunch of
different classes all named Create spread across a number of different
packages. That's legal Java, but it isn't ideal. You may find yourself
accidentally editing the Java code for creating an Account when you really want
to be editing the code for creating a Payment.</span></p><p>Tapestry is
encouraging you to use a more descriptive name: Create<em>Address</em>, not
just Create, but it isn't making you pay the cost (in terms of longer, uglier
URLs). The URL to access the page will still be <a shape="rect"
class="external-link" href="http://localhost:8080
/tutorial1/address/create"
>http://localhost:8080/tutorial1/address/create</a>.</p><p>And remember,
regardless of the name that Tapestry assigns to your page, the template file is
named like the Java class itself: CreateAddress.tml.</p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Index pages work in folders as
well. A class named com.example.tutorial1.pages.address.AddressIndex would be
given the name "address/Index". However, Tapestry has special rules for pages
named "Index" and the rendered URL would be <a shape="rect"
class="external-link" href="http://localhost:8080/tutorial1/address/"
>http://localhost:8080/tutorial1/address/</a>. In other words, you can place
Index pages in any folder and Tapestry will build a short URL for that page ...
and you <em>don't</em> have to keep naming the classes In
dex (it's confusing to have many classes with the same name, even across
multiple packages); instead, you can name each index page after the package
that contains it. Tapestry users a smart <em>convention</em> to keep it all
straight and generate short, to the point URLs.</p></div></div><h1
id="UsingBeanEditFormToCreateUserForms-UsingtheBeanEditFormComponent">Using the
BeanEditForm Component</h1><p>Time to start putting together the logic for this
form. Tapestry has a specific component for client-side Forms: the <a
shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Form.html">Form</a>
component, as well as components for form controls, such as <a shape="rect"
class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Checkbox.html">Checkbox</a>
and <a shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/core
lib/components/TextField.html">TextField</a>. We'll cover those in a bit more
detail later .. instead, we're again going to let Tapestry do the heavy lifting
for us, via the <a shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/BeanEditForm.html">BeanEditForm</a>
component.</p><p>Add the following to the CreateAddress template (replacing
the "coming soon ..." message):</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>CreateAddress.tml (partial)</b></div><div
class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default"
style="font-size:12px;"> <t:beaneditform object="address"/>
</pre>
</div></div><p>And match that up with a property in the CreateAddress
class:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>CreateAddress.java (partial)</b></div><div class="codeContent
panelContent pdl">
Modified:
websites/production/tapestry/content/using-tapestry-with-hibernate.html
==============================================================================
--- websites/production/tapestry/content/using-tapestry-with-hibernate.html
(original)
+++ websites/production/tapestry/content/using-tapestry-with-hibernate.html Sun
Aug 9 16:20:08 2015
@@ -100,8 +100,8 @@
</session-factory>
</hibernate-configuration>
</pre>
-</div></div><p>Most of the configuration is to identify the JDBC driver and
connection URL.</p><p>Note the connection URL. We are instructing HSQLDB to
store its database files within our project's target directory. We are also
instructing HSQLDB to flush any data to these files at shutdown. This means
that data will persist across different invocations of this project, but if the
target directory is destroyed (e.g., via "mvn clean"), then all the database
contents will be lost.</p><p>In addition, we are configuring Hibernate to
<em>update</em> the database schema; when Hibernate initializes it will create
or even modify tables to match the entities. Finally, we are configuring
Hibernate to output any SQL it executes, which is very useful when initially
building an application.</p><p>But what entities? Normally, the available
entities are listed inside hibernate.cfg.xml, but that's not necessary with
Tapestry; in another example of convention over configuration, Tapestry locates
all
entity classes inside the entities package ("com.example.tutorial.entities"
in our case) and adds them to the configuration. Currently, that is just the
Address entity.</p><h2
id="UsingTapestryWithHibernate-AddingHibernateAnnotations">Adding Hibernate
Annotations</h2><p>For an entity class to be used with Hibernate, some
Hibernate annotations must be added to the class.</p><p>Below is the updated
Address class, with the Hibernate annotations (as well as the Tapestry
ones).</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/entities/Address.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.entities;
+</div></div><p>Most of the configuration is to identify the JDBC driver and
connection URL.</p><p>Note the connection URL. We are instructing HSQLDB to
store its database files within our project's target directory. We are also
instructing HSQLDB to flush any data to these files at shutdown. This means
that data will persist across different invocations of this project, but if the
target directory is destroyed (e.g., via "mvn clean"), then all the database
contents will be lost.</p><p>In addition, we are configuring Hibernate to
<em>update</em> the database schema; when Hibernate initializes it will create
or even modify tables to match the entities. Finally, we are configuring
Hibernate to output any SQL it executes, which is very useful when initially
building an application.</p><p>But what entities? Normally, the available
entities are listed inside hibernate.cfg.xml, but that's not necessary with
Tapestry; in another example of convention over configuration, Tapestry locates
all
entity classes inside the entities package ("com.example.tutorial1.entities"
in our case) and adds them to the configuration. Currently, that is just the
Address entity.</p><h2
id="UsingTapestryWithHibernate-AddingHibernateAnnotations">Adding Hibernate
Annotations</h2><p>For an entity class to be used with Hibernate, some
Hibernate annotations must be added to the class.</p><p>Below is the updated
Address class, with the Hibernate annotations (as well as the Tapestry
ones).</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/entities/Address.java</b></div><div
class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -111,7 +111,7 @@ import javax.persistence.Id;
import org.apache.tapestry5.beaneditor.NonVisual;
import org.apache.tapestry5.beaneditor.Validate;
-import com.example.tutorial.data.Honorific;
+import com.example.tutorial1.data.Honorific;
@Entity
public class Address
@@ -148,10 +148,10 @@ public class Address
}
</pre>
</div></div><p>The Tapestry annotations, @NonVisual and @Validate, may be
placed on the setter or getter method or on the field (as we have done here).
As with the Hibernate annotations, putting the annotation on the field requires
that the field name match the corresponding property
name.</p><ul><li><strong>@NonVisual</strong> – indicates a field, such as
a primary key, that should not be made visible to the
user.</li><li><strong>@Validate</strong> – identifies the validations
associated with a field.</li></ul><p>At this point you should stop and restart
your application.</p><h2
id="UsingTapestryWithHibernate-UpdatingtheDatabase">Updating the
Database</h2><p>So we have a database set up, and Hibernate is configured to
connect to it. Let's make use of that to store our Address object in the
database.</p><p>What we need is to provide some code to be executed when the
form is submitted. When a Tapestry form is submitted, there is a whole series
of events that get fired. Th
e event we are interested in is the "success" event, which comes late in the
process, after all the values have been pulled out of the request and applied
to the page properties, and after all server-side validations have
occurred.</p><p>The success event is only fired if there are no validation
errors.</p><p>Our event handler must do two things:</p><ul><li>Use the
Hibernate Session object to persist the new Address object.</li><li>Commit the
transaction to force the data to be written to the database.</li></ul><p>Let's
update our CreateAddress.java class:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/pages/address/CreateAddress.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages.address;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages.address;
-import com.example.tutorial.entities.Address;
-import com.example.tutorial.pages.Index;
+import com.example.tutorial1.entities.Address;
+import com.example.tutorial1.pages.Index;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
@@ -183,11 +183,11 @@ public class CreateAddress
include="honorific,firstName,lastName,street1,city,state,zip,phone"/>
</pre>
</div></div><p>Note that the Grid component accepts many of the same
parameters that we used with the BeanEditForm. Here we use the include
parameter to specify the properties to show, and in what order.</p><p>Now all
we have to do is supply the addresses property in the Java code. Here's how
Index.java should look now:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width:
1px;"><b>src/main/java/com/example/tutorial/pages/Index.java</b></div><div
class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial.pages;
+<pre class="brush: java; gutter: false; theme: Default"
style="font-size:12px;">package com.example.tutorial1.pages;
import java.util.List;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;
-import com.example.tutorial.entities.Address;
+import com.example.tutorial1.entities.Address;
public class Index
{
@Inject