You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bu...@apache.org on 2013/02/02 15:20:51 UTC
svn commit: r849080 - in /websites/production/tapestry/content:
ajax-and-zones.html cache/main.pageCache component-parameters.html
page-life-cycle.html
Author: buildbot
Date: Sat Feb 2 14:20:51 2013
New Revision: 849080
Log:
Production update by buildbot for tapestry
Modified:
websites/production/tapestry/content/ajax-and-zones.html
websites/production/tapestry/content/cache/main.pageCache
websites/production/tapestry/content/component-parameters.html
websites/production/tapestry/content/page-life-cycle.html
Modified: websites/production/tapestry/content/ajax-and-zones.html
==============================================================================
--- websites/production/tapestry/content/ajax-and-zones.html (original)
+++ websites/production/tapestry/content/ajax-and-zones.html Sat Feb 2 14:20:51 2013
@@ -180,8 +180,8 @@
void onActionFromRegister()
{
- ajaxResponseRenderer.addRender(<span class="code-quote">"userInput"</span>, userInput)
- .addRender(<span class="code-quote">"helpPanel"</span>, helpPanel);
+ ajaxResponseRenderer.addRender(<span class="code-quote">"userInput"</span>,
+ userInput).addRender(<span class="code-quote">"helpPanel"</span>, helpPanel);
}
</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
@@ -194,8 +194,9 @@ void onActionFromRegister()
<span class="code-object">Object</span> onActionFromRegister()
{
- <span class="code-keyword">return</span> <span class="code-keyword">new</span> MultiZoneUpdate(<span class="code-quote">"userInput"</span>, registrationForm)
- .add(<span class="code-quote">"helpPanel"</span>, registrationHelp);
+ <span class="code-keyword">return</span> <span class="code-keyword">new</span> MultiZoneUpdate(<span class="code-quote">"userInput"</span>,
+ registrationForm).add(<span class="code-quote">"helpPanel"</span>,
+ registrationHelp);
}
</pre>
</div></div>
@@ -205,6 +206,31 @@ void onActionFromRegister()
<p>These examples assume that there are two zones, "userInput" and "helpPanel", somewhere in the rendered page, waiting to receive the updated content.</p>
+<h3><a shape="rect" name="AjaxandZones-ZoneComponentIdvs.ZoneElementId"></a>Zone Component Id vs. Zone Element Id</h3>
+
+<p>Like all Tapestry components, Zones have a component id, specified using the <tt>t:id</tt> attribute. If you do not assign a component id, a unique id is assigned by Tapestry.</p>
+
+<p>However, to coordinate things on the client side, it is necessary for components that wish to update the zone know the <em>client-side element id</em>. This is specified with the <tt>id</tt> parameter of the Zone component. If the <tt>id</tt> parameter is not bound, then a unique value (for the current page and render) is generated by Tapestry and this value is difficult to predict. The actual value will be available as the <tt>clientId</tt> property of the Zone component itself.</p>
+
+<p>Remember that the component id (<tt>t:id</tt>) is used to <em>inject</em> the Zone component into the containing page or component. The<br clear="none">
+client-side id (<tt>id</tt>) is used ... on the client side to orchestrate requests and updates. You will often seen the following construct:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-xml">
+<span class="code-tag"><t:zone t:id=<span class="code-quote">"myZone"</span> id=<span class="code-quote">"myzone"</span>></span> ... <span class="code-tag"></t:zone></span>
+
+<span class="code-tag"><t:actionlink t:id=<span class="code-quote">"update"</span> zone=<span class="code-quote">"myzone"</span>></span>update<span class="code-tag"></t:actionlink></span>
+</pre>
+</div></div>
+
+
+
+
+<div class="panelMacro"><table class="infoMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="https://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1"><b>Added in 5.2</b><br clear="none"></td></tr></table></div>
+<div style="border-right: 20px solid #D8E4F1;border-left: 20px solid #D8E4F1;">
+<p>If the Form or Link is enclosed by the Zone itself, then the <tt>zone</tt> parameter may be set to the special value <tt>^</tt>. The carat is evaluated, on the client side, by searching up form the form or link element for the first enclosing element with the <tt>t-zone</tt> CSS class. In this way, the client-side coordination can occur without having to know what the specific client-side id of the Zone is. Because of this, in many cases, it is no longer necessary to specify the Zone's <tt>id</tt> parameter.</p>
+</div>
+
<h3><a shape="rect" name="AjaxandZones-AnUpdatedivwithinaZonediv"></a>An Update div within a Zone div</h3>
@@ -244,32 +270,6 @@ Tapestry.ElementEffect.myeffectname = <s
</pre>
</div></div>
-<h3><a shape="rect" name="AjaxandZones-ZoneComponentIdvs.ZoneElementId"></a>Zone Component Id vs. Zone Element Id</h3>
-
-<p>Like all Tapestry components, Zones have a component id, specified using the <tt>t:id</tt> attribute. If you do not assign a component id, a unique id is assigned by Tapestry.</p>
-
-<p>However, to coordinate things on the client side, it is necessary for components that wish to update the zone know the <em>client-side element id</em>. This is specified with the <tt>id</tt> parameter of the Zone component. If the <tt>id</tt> parameter is not bound, then a unique value (for the current page and render) is generated by Tapestry and this value is difficult to predict. The actual value will be available as the <tt>clientId</tt> property of the Zone component itself.</p>
-
-<p>Remember that the component id (<tt>t:id</tt>) is used to <em>inject</em> the Zone component into the containing page or component. The<br clear="none">
-client-side id (<tt>id</tt>) is used ... on the client side to orchestrate requests and updates. You will often seen the following construct:</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-<span class="code-tag"><t:zone t:id=<span class="code-quote">"myZone"</span> id=<span class="code-quote">"myzone"</span>></span> ... <span class="code-tag"></t:zone></span>
-
-<span class="code-tag"><t:actionlink t:id=<span class="code-quote">"update"</span> zone=<span class="code-quote">"myzone"</span>></span>update<span class="code-tag"></t:actionlink></span>
-</pre>
-</div></div>
-
-
-
-
-<div class="panelMacro"><table class="infoMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="https://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1"><b>Added in 5.2</b><br clear="none"></td></tr></table></div>
-<div style="border-right: 20px solid #D8E4F1;border-left: 20px solid #D8E4F1;">
-<p>If the Form or Link is enclosed by the Zone itself, then the <tt>zone</tt> parameter may be set to the special value <tt>^</tt>. The carat is evaluated, on the client side, by searching up form the form or link element for the first enclosing element with the <tt>t-zone</tt> CSS class. In this way, the client-side coordination can occur without having to know what the specific client-side id of the Zone is. Because of this, in many cases, it is no longer necessary to specify the Zone's <tt>id</tt> parameter.</p>
-</div>
-
-
<h3><a shape="rect" name="AjaxandZones-ZoneLimitations"></a>Zone Limitations</h3>
<p>Unlike many other situations, Tapestry relies on you to specify useful and unique ids to Zone components, then reference those ids inside EventLink (or ActionLink, or Form) components. Using Zone components inside any kind of loop may cause additional problems, as Tapestry will <em>uniqueify</em> the client id you specify (appending an index number).</p>
Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/tapestry/content/component-parameters.html
==============================================================================
--- websites/production/tapestry/content/component-parameters.html (original)
+++ websites/production/tapestry/content/component-parameters.html Sat Feb 2 14:20:51 2013
@@ -103,7 +103,8 @@
<p>In the following example, <tt>page</tt> is a parameter of the <tt>pagelink</tt> component. The page parameter tells the pagelink component which page to go to when the user clicks on the rendered hyperlink:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><html <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
+<pre class="code-xml">
+<span class="code-tag"><html <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
<span class="code-tag"><t:pagelink page=<span class="code-quote">"Index"</span>></span>Go Home<span class="code-tag"></t:pagelink></span>
<span class="code-tag"></html></span>
</pre>
@@ -113,7 +114,7 @@
<p>Within a component class, parameters are declared by using the @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Parameter.html">Parameter</a> annotation on a private field.</p>
-<p>In Tapestry, a parameter is not a slot into which data is pushed: it is a <em>connection</em> between a field of the component (marked with the @Parameter annotation) and a property or resource of the component's container. In most simple examples, the component's container is the page, but since components can have templates, often the container of a component is another component.</p>
+<p>In Tapestry, a parameter is not a slot into which data is pushed: it is a <em>connection</em> between a field of the component (marked with the @Parameter annotation) and a property or resource of the component's container. In most simple examples, the component's container is the page, but since components can be nested, often the container of a component is another component.</p>
<p>The connection between a component and a property (or resource) of its container is called a <em>binding</em>. The binding is two-way: the component can read the bound property by reading its parameter field. Likewise, a component that updates its parameter field will update the bound property.</p>
@@ -122,7 +123,8 @@
<p>The component listed below is a looping component; it renders its body a number of times, defined by its <tt>start</tt> and <tt>end</tt> parameters (which set the boundaries of the loop). The component can update a <tt>result</tt> parameter bound to a property of its container; it will automatically count up or down depending on whether <tt>start</tt> or <tt>end</tt> is larger.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java"><span class="code-keyword">package</span> org.example.app.components;
+<pre class="code-java">
+<span class="code-keyword">package</span> org.example.app.components;
<span class="code-keyword">import</span> org.apache.tapestry5.annotations.AfterRender;
<span class="code-keyword">import</span> org.apache.tapestry5.annotations.Parameter;
@@ -185,7 +187,8 @@
<p>The component above can be referenced in another component or page <a shape="rect" href="component-templates.html" title="Component Templates">template</a>, and its parameters <em>bound</em>:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><html t:type=<span class="code-quote">"layout"</span> <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
+<pre class="code-xml">
+<span class="code-tag"><html t:type=<span class="code-quote">"layout"</span> <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
<span class="code-tag"><p></span> Merry Christmas: <span class="code-tag"><t:count end=<span class="code-quote">"3"</span>></span> Ho! <span class="code-tag"></t:count></span>
<span class="code-tag"></p></span>
<span class="code-tag"></html></span>
@@ -207,13 +210,13 @@
<p>By placing a prefix in front of the value, you can change how Tapestry interprets the remainder of the expression (the part after the colon):</p>
<div class="table-wrap">
-<table class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" class="confluenceTd"> <b>Prefix</b> </td><td colspan="1" rowspan="1" class="confluenceTd"> <b>Description</b> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> asset: </td><td colspan="1" rowspan="1" class="confluenceTd"> The relative path to an asset file (which must exist) </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> block: </td><td colspan="1" rowspan="1" class="confluenceTd"> The id of a block within the template </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> component: </td><td colspan="1" rowspan="1" class="confluenceTd"> The id of another component within the same template </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> context: </td><td colspan="1" rowspan="1" class="confluenceTd"> Context asset: path from context root </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> literal: </td><td colspan="1" rowspan="1" class="con
fluenceTd"> A literal string. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> nullfieldstrategy: </td><td colspan="1" rowspan="1" class="confluenceTd"> Used to locate a pre-defined <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/NullFieldStrategy.html">NullFieldStrategy</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> message: </td><td colspan="1" rowspan="1" class="confluenceTd"> Retrieves a string from the component's <a shape="rect" href="#ComponentParameters-localization.html">message catalog</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> prop: </td><td colspan="1" rowspan="1" class="confluenceTd"> A <a shape="rect" href="property-expressions.html" title="Property Expressions">property expression</a> to read or update </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> symbol: </td><td colspan="1" rowspan="1" class="confluenceTd"> Used to read o
ne of your <a shape="rect" href="symbols.html" title="Symbols">symbols</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> translate: </td><td colspan="1" rowspan="1" class="confluenceTd"> The name of a configured translator </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> validate: </td><td colspan="1" rowspan="1" class="confluenceTd"> A <em>validator specification</em> used to create some number of field validators </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> var: </td><td colspan="1" rowspan="1" class="confluenceTd"> Allows a render variable of the component to be read or updated </td></tr></tbody></table>
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"> <b>Prefix</b> </th><th colspan="1" rowspan="1" class="confluenceTh"> <b>Description</b> </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> asset: </td><td colspan="1" rowspan="1" class="confluenceTd"> The relative path to an asset file (which must exist) </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> block: </td><td colspan="1" rowspan="1" class="confluenceTd"> The id of a block within the template </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> component: </td><td colspan="1" rowspan="1" class="confluenceTd"> The id of another component within the same template </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> context: </td><td colspan="1" rowspan="1" class="confluenceTd"> Context asset: path from context root </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> literal: </td><td colspan="1" rowspan="1" class="con
fluenceTd"> A literal string </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> nullfieldstrategy: </td><td colspan="1" rowspan="1" class="confluenceTd"> Used to locate a pre-defined <a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/NullFieldStrategy.html">NullFieldStrategy</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> message: </td><td colspan="1" rowspan="1" class="confluenceTd"> Retrieves a string from the component's <a shape="rect" href="#ComponentParameters-localization.html">message catalog</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> prop: </td><td colspan="1" rowspan="1" class="confluenceTd"> A <a shape="rect" href="property-expressions.html" title="Property Expressions">property expression</a> to read or update </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> symbol: </td><td colspan="1" rowspan="1" class="confluenceTd"> Used to read on
e of your <a shape="rect" href="symbols.html" title="Symbols">symbols</a> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> translate: </td><td colspan="1" rowspan="1" class="confluenceTd"> The name of a configured translator </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> validate: </td><td colspan="1" rowspan="1" class="confluenceTd"> A <em>validator specification</em> used to create some number of field validators </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> var: </td><td colspan="1" rowspan="1" class="confluenceTd"> Allows a render variable of the component to be read or updated </td></tr></tbody></table>
</div>
<p>Most of these binding prefixes allow parameters to be bound to read-only values; for instance a parameter bound to "message:some-key" will see the message for "some-key" from its container's message catalog in the field. If the component tries to update the parameter (by setting the value of the field), a runtime exception will be thrown to indicate that the value is read-only.</p>
-<p>Only prop: and var: binding prefixes are updateable (but you must <em>not</em> use the ${..} syntax here; see the next section).</p>
+<p>Only prop: and var: binding prefixes are updateable (but you must <em>not</em> use the ${..} syntax here; see the <a shape="rect" href="#ComponentParameters-dontUseSyntax">warning below</a>).</p>
<p>Each parameter has a default prefix, defined by the component, that is used when the prefix is not provided. The most common are "literal:" and "prop:".</p>
@@ -225,20 +228,23 @@
<p>For example, the following template code:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><ul></span>
+<pre class="code-xml">
+<span class="code-tag"><ul></span>
<span class="code-tag"><li t:type=<span class="code-quote">"loop"</span> source=<span class="code-quote">"1..10"</span> value=<span class="code-quote">"index"</span>></span>${index}<span class="code-tag"></li></span>
<span class="code-tag"></ul></span>
</pre>
</div></div>
<p>and the following Java code:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">@Property
+<pre class="code-java">
+@Property
<span class="code-keyword">private</span> <span class="code-object">int</span> index;
</pre>
</div></div>
<p>... could be rewritten as just:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><ul></span>
+<pre class="code-xml">
+<span class="code-tag"><ul></span>
<span class="code-tag"><li t:type=<span class="code-quote">"loop"</span> source=<span class="code-quote">"1..10"</span> value=<span class="code-quote">"var:index"</span>></span>${var:index}<span class="code-tag"></li></span>
<span class="code-tag"></ul></span>
@@ -282,7 +288,8 @@
<p>Context bindings are like asset bindings, but the path is <em>always</em> relative to the root of the web application context. This is intended for use inside templates, i.e.:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"> <span class="code-tag"><img src=<span class="code-quote">"${context:images/icon.png}"</span>/></span>
+<pre class="code-xml">
+ <span class="code-tag"><img src=<span class="code-quote">"${context:images/icon.png}"</span>/></span>
</pre>
</div></div>
<p>Tapestry will adjust the URL of the image so that it is processed by Tapestry, not the servlet container. It will gain a URL that includes the application's version number, it will have a far-future expires header, and (if the client supports it) its content will be compressed before being sent to the client.</p>
@@ -316,7 +323,8 @@
<p>The @Parameter annotation's <tt>value</tt> element can be used to specify a <em>binding expression</em> that will be the default binding for the parameter if otherwise left unbound. Typically, this is the name of a property that that will compute the value on the fly.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">@Parameter(value=<span class="code-quote">"defaultMessage"</span>) <span class="code-comment">// or, equivalently, @Parameter(<span class="code-quote">"defaultMessage"</span>)
+<pre class="code-java">
+@Parameter(value=<span class="code-quote">"defaultMessage"</span>) <span class="code-comment">// or, equivalently, @Parameter(<span class="code-quote">"defaultMessage"</span>)
</span><span class="code-keyword">private</span> <span class="code-object">String</span> message;
@Parameter(required=<span class="code-keyword">true</span>)
@@ -337,6 +345,7 @@
<p>In rare cases, it is desirable to defeat the caching; this can be done by setting the cache() attribute of the @Parameter annotation to false.</p>
+<p><a shape="rect" name="ComponentParameters-dontUseSyntax"></a></p>
<h1><a shape="rect" name="ComponentParameters-Don%27tusethe%24%5Csyntax%5C%21"></a>Don't use the ${...} syntax!</h1>
<p>Main Article: <a shape="rect" href="component-templates.html#ComponentTemplates-Expansions">Component Templates#Expansions</a></p>
@@ -345,11 +354,13 @@
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>This is right</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><t:textfield t:id=<span class="code-quote">"color"</span> value=<span class="code-quote">"color"</span>/></span>
+<pre class="code-xml">
+<span class="code-tag"><t:textfield t:id=<span class="code-quote">"color"</span> value=<span class="code-quote">"color"</span>/></span>
</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>This is wrong</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><t:textfield t:id=<span class="code-quote">"color"</span> value=<span class="code-quote">"${color}"</span>/></span>
+<pre class="code-xml">
+<span class="code-tag"><t:textfield t:id=<span class="code-quote">"color"</span> value=<span class="code-quote">"${color}"</span>/></span>
</pre>
</div></div></td></tr></tbody></table>
@@ -357,11 +368,13 @@
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>This is right</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><img src=<span class="code-quote">"${context:images/banner.png}"</span>/></span>
+<pre class="code-xml">
+<span class="code-tag"><img src=<span class="code-quote">"${context:images/banner.png}"</span>/></span>
</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>This is wrong</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><img src=<span class="code-quote">"context:images/banner.png"</span>/></span>
+<pre class="code-xml">
+<span class="code-tag"><img src=<span class="code-quote">"context:images/banner.png"</span>/></span>
</pre>
</div></div></td></tr></tbody></table>
@@ -382,7 +395,8 @@
<p>Parameters are not simply variables; each parameter represents a connection, or <em>binding</em>, between a component and a property of its container. When using the prop: binding prefix, the component can force changes <em>into</em> a property of its container, just by assigning a value to its own instance variable.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><t:layout <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
+<pre class="code-xml">
+<span class="code-tag"><t:layout <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
<span class="code-tag"><p></span> Countdown:
<span class="code-tag"><t:count start=<span class="code-quote">"5"</span> end=<span class="code-quote">"1"</span> result=<span class="code-quote">"index"</span>></span>
${index} ...
@@ -395,7 +409,8 @@
<p>Because the Count component updates its result parameter (the <tt>result</tt> field), the index property of the containing component is updated. Inside the Count's body, we output the current value of the index property, using the expansion <tt>${index</tt>}. The resulting output will look something like:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml"> <span class="code-tag"><p></span> Countdown: 5 ... 4 ... 3 ... 2 ... 1 ... <span class="code-tag"></p></span>
+<pre class="code-xml">
+ <span class="code-tag"><p></span> Countdown: 5 ... 4 ... 3 ... 2 ... 1 ... <span class="code-tag"></p></span>
</pre>
</div></div>
@@ -412,7 +427,8 @@
<p>Inherited bindings are useful for complex components; they are often used when an inner component has a default value for a parameter, and the outer component wants to make it possible to override that default.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Index.tml</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><html <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
+<pre class="code-xml">
+<span class="code-tag"><html <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
<span class="code-tag"><body></span>
<span class="code-tag"><div t:type=<span class="code-quote">"layout"</span> t:menuTitle=<span class="code-quote">"literal:The Title"</span>></span>
...
@@ -424,7 +440,8 @@
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Layout.tml</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><t:container <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
+<pre class="code-xml">
+<span class="code-tag"><t:container <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
<span class="code-tag"><div t:type=<span class="code-quote">"title"</span> t:title=<span class="code-quote">"inherit:menuTitle"</span>></span><span class="code-tag"></div></span>
@@ -436,7 +453,8 @@
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Title.java</b></div><div class="codeContent panelContent">
-<pre class="code-java"><span class="code-keyword">package</span> org.example.app.components;
+<pre class="code-java">
+<span class="code-keyword">package</span> org.example.app.components;
<span class="code-keyword">import</span> org.apache.tapestry5.annotations.Parameter;
@@ -458,7 +476,8 @@
<p>Using this approach, the previous example may be rewritten as:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java"> @Parameter
+<pre class="code-java">
+ @Parameter
<span class="code-keyword">private</span> <span class="code-object">String</span> message;
@Parameter(required=<span class="code-keyword">true</span>)
@@ -487,7 +506,8 @@
<p>Alternately, the previous example may be written even more succinctly as:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java"> @Parameter
+<pre class="code-java">
+ @Parameter
<span class="code-keyword">private</span> <span class="code-object">String</span> message;
@Parameter(required=<span class="code-keyword">true</span>)
@@ -534,7 +554,8 @@
<p>In rare cases, you may want to take different behaviors based on whether a parameter is bound or not. This can be accomplished by querying the component's resources, which can be <a shape="rect" href="injection.html" title="Injection">injected</a> into the component using the @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Inject.html">Inject</a> annotation:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java"><span class="code-keyword">public</span> class MyComponent
+<pre class="code-java">
+<span class="code-keyword">public</span> class MyComponent
{
@Parameter
<span class="code-keyword">private</span> <span class="code-object">int</span> myParam;
@@ -567,7 +588,8 @@
<p>In Tapestry 5.1 and later, you may use the publishParameters attribute of the @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Component.html">Component</a> annotation. List one or more parameters separated by commas: those parameters of the inner/embedded component become parameters of the outer component. You should <b>not</b> define a parameter field in the outer component.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>ContainerComponent.tml</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><t:container <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
+<pre class="code-xml">
+<span class="code-tag"><t:container <span class="code-keyword">xmlns:t</span>=<span class="code-quote">"http://tapestry.apache.org/schema/tapestry_5_3.xsd"</span>></span>
<span class="code-tag"><t:pageLink t:id=<span class="code-quote">"link"</span>></span>Page Link<span class="code-tag"></t:pageLink></span>
<span class="code-tag"></t:container></span>
</pre>
@@ -582,7 +604,8 @@
</div></div>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>Index.tml</b></div><div class="codeContent panelContent">
-<pre class="code-xml"><span class="code-tag"><t:ContainerComponent t:id=<span class="code-quote">"Container"</span> t:page=<span class="code-quote">"About"</span> /></span>
+<pre class="code-xml">
+<span class="code-tag"><t:ContainerComponent t:id=<span class="code-quote">"Container"</span> t:page=<span class="code-quote">"About"</span> /></span>
</pre>
</div></div>
Modified: websites/production/tapestry/content/page-life-cycle.html
==============================================================================
--- websites/production/tapestry/content/page-life-cycle.html (original)
+++ websites/production/tapestry/content/page-life-cycle.html Sat Feb 2 14:20:51 2013
@@ -63,10 +63,6 @@
</td></tr><tr><td colspan="1" rowspan="1">
<span class="icon icon-page" title="Page">Page:</span>
- <a shape="rect" href="page-life-cycle.html">Page Life Cycle</a>
-
- </td></tr><tr><td colspan="1" rowspan="1">
- <span class="icon icon-page" title="Page">Page:</span>
<a shape="rect" href="request-processing.html">Request Processing</a>
</td></tr><tr><td colspan="1" rowspan="1">
@@ -81,36 +77,51 @@
<span class="icon icon-page" title="Page">Page:</span>
<a shape="rect" href="page-navigation.html">Page Navigation</a>
+ </td></tr><tr><td colspan="1" rowspan="1">
+ <span class="icon icon-page" title="Page">Page:</span>
+ <a shape="rect" href="page-life-cycle.html">Page Life Cycle</a>
+
</td></tr></table>
</div>
<p>In Tapestry, you are free to develop your presentation objects, page and components classes, as ordinary objects, complete with instance variables and so forth.</p>
-<p>This is somewhat revolutionary in terms of web development in Java. Using servlets, or Struts, your presentation objects (Servlets, or Struts Actions, or the equivalent in other frameworks) are <em>stateless singletons</em>. That is, a <em>single</em> instance is created, and all incoming requests are threaded through that single instance.</p>
+<p>This is somewhat revolutionary in terms of web development in Java. Using traditional servlets, or Struts, your presentation objects (Servlets, or Struts Actions, or the equivalent in other frameworks) are <em>stateless singletons</em>. That is, a <em>single</em> instance is created, and all incoming requests are threaded through that single instance.</p>
<p>Because multiple requests are handled by many different threads, this means that the single instance's variable are useless ... any value written into an instance variable would immediately be overwritten by a different thread. Thus, it is necessary to use the Servlet API's HttpServletRequest object to store per-request data, and the HttpSession object to store data between requests.</p>
<p>Tapestry takes a very different approach.</p>
-<p>In Tapestry, you will have many different instances of any particular page, each either in use for a single request (on a single thread), or waiting in a <em>page pool</em> to be used.</p>
+<p>In Tapestry, each page is a singleton, but with a <em>per thread</em> map of field names & values that Tapestry invisibly manages for you.</p>
+
+<p>With this approach, all the difficult, ugly issues related to multi-threading go by the wayside. Instead, familiar, simple coding practices (using ordinary methods and fields) can be used.</p>
-<p>By reserving page instances to particular threads, all the difficult, ugly issues related to multi-threading go by the wayside. Instead, familiar, simple coding practices (using ordinary methods and fields) can be used.</p>
+<div class="panelMacro"><table class="infoMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="https://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1">Tapestry 5.0 and 5.1 used page pooling, rather than a singleton page with a per_thread map, to achieve the same effect.</td></tr></table></div>
-<p>However, there's a risk: it would be a disaster if data could "bleed" from one request to another. Imagine the outcome in a banking application if the first user's account number and password became the default for the second user to reach the application!</p>
+<h2><a shape="rect" name="PageLifeCycle-PageLifeCycleMethods"></a>Page Life Cycle Methods</h2>
-<p>Tapestry takes special care to purge all instance variables back to their default value at the end of each request.</p>
+<p>There are a few situations where it is useful for a component to perform some operations, usually some kind of initialization or caching, based on the life cycle of the page.</p>
-<p>The end result is that all pages in the pool are entirely equivalent to each other; it doesn't matter which instance is used for processing any particular request.</p>
+<p>The page life cycle is quite simple. When first needed, a page is loaded. Loading a page involves instantiating the components of the page and connecting them together.</p>
-<p>Remember that the page instance is just the tip of the iceberg: a page instance encompasses the page component, its templates, all of its parameter bindings, tokens read from its template and (recursively) the same thing for all components inside the page. It adds up.</p>
+<p>Once a page is loaded, it is <em>attached</em> to the current request. Remember that there will be many threads, each handling its own request to the same page.</p>
-<p>A page instance will be "checked out" of the pool for a short period of time: a few milliseconds to service a typical request. Because of this, it is generally the case that Tapestry can handle a large number of end users with a relatively small pool of page instances.</p>
+<p>At the end of a request, after a response has been sent to the client, the page is <em>detached</em> from the request. This is a chance to perform any cleanup needed for the page.</p>
+
+<p>As with <a shape="rect" href="component-rendering.html" title="Component Rendering">component rendering</a>, you have the ability to make your components "aware" of these events by identifying methods to be invoked.</p>
+
+<p>Page life cycle methods should take no parameters and return void.</p>
+
+<p>You have the choice of attaching an annotation to a method, or simply using the method naming conventions:</p>
+
+<div class="table-wrap">
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"> Annotation </th><th colspan="1" rowspan="1" class="confluenceTh"> Method Name </th><th colspan="1" rowspan="1" class="confluenceTh"> When Called </th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/PageLoaded.html">PageLoaded</a></td><td colspan="1" rowspan="1" class="confluenceTd">pageLoaded()</td><td colspan="1" rowspan="1" class="confluenceTd"> After the page is fully loaded </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/PageAttached.html">PageAttached</a> </td><td colspan="1" rowspan="1" class="confluenceTd"> pageAttached() </td><td colspan="1" rowspan="1" class="confluenceTd"> After the page is attached to the requ
est. <b>Deprecated in Tapestry 5.3</b> </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> @<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/PageDetached.html">PageDetached</a> </td><td colspan="1" rowspan="1" class="confluenceTd"> pageDetached() </td><td colspan="1" rowspan="1" class="confluenceTd"> AFter the page is detached from the request. <b>Deprecated in Tapestry 5.3</b> </td></tr></tbody></table>
+</div>
-<h2><a shape="rect" name="PageLifeCycle-ComparisontoJavaServerPages"></a>Comparison to JavaServer Pages</h2>
-<p>JSPs also use a caching mechanism; the JSP itself is compiled into a Java servlet class, and acts as a singleton.</p>
+<h2><a shape="rect" name="PageLifeCycle-ComparisontoJavaServerPages"></a>Comparison to JavaServer Pages</h2>
-<p>However, the individual JSP tags are pooled.</p>
+<p>JSPs also act as singletons. However, the individual JSP tags are pooled.</p>
<p>This is one of the areas where Tapestry can significantly outperform JSPs. Much of the code inside a compiled JSP class concerns getting tags from a tag pool, configuring the properties of the tag instance, using the tag instance, then cleaning up the tag instance and putting it back in the pool.</p>
@@ -124,7 +135,7 @@
<div class="panelMacro"><table class="noteMacro"><colgroup span="1"><col span="1" width="24"><col span="1"></colgroup><tr><td colspan="1" rowspan="1" valign="top"><img align="middle" src="https://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" width="16" height="16" alt="" border="0"></td><td colspan="1" rowspan="1">As of 5.2, Tapestry does <em>not</em> employ page pooling by default</td></tr></table></div>
-<p>Tapestry's page pool is used to store page instances. The pool is "keyed" on the name of the page (such as "start") and the <em>locale</em> for the page (such as "en" or "fr").</p>
+<p>In Tapestry 5.0 and 5.1, a page pool is used to store page instances. The pool is "keyed" on the name of the page (such as "start") and the <em>locale</em> for the page (such as "en" or "fr").</p>
<p>Within each key, Tapestry tracks the number of page instances that have been created, as well as the number that are in use (currently attached to a request).</p>
@@ -143,26 +154,6 @@ Thus a busy application will initially c
<p>The end result is that you have quite a degree of tuning control over the process. If memory is a limitation and throughput can be sacrificed, try lowering the soft and hard limit and increasing the soft wait.</p>
<p>If performance is absolute and you have lots of memory, then increase the soft and hard limit and reduce the soft wait. This encourages Tapestry to create more page instances and not wait as long to re-use existing instances.</p>
-
-<h2><a shape="rect" name="PageLifeCycle-PageLifeCycleMethods"></a>Page Life Cycle Methods</h2>
-
-<p>There are a few situations where it is useful for a component to perform some operations, usually some kind of initialization or caching, based on the life cycle of the page.</p>
-
-<p>The page life cycle is quite simple. When first needed, a page is loaded. Loading a page involves instantiating the components of the page and connecting them together.</p>
-
-<p>Once a page is loaded, it is <em>attached</em> to the current request. Remember that there will be many threads, each handling its own request. In many cases, there will be multiple copies of the same page attached to different requests (and different threads). This is how Tapestry keeps you from worrying about multi-threading issues ... the objects involved in any request are reserved to <em>just</em> that request (and <em>just</em> that thread).</p>
-
-<p>At the end of a request, after a response has been sent to the client, the page is <em>detached</em> from the request. This is a chance to perform a lot of cleanup of the page, discarding temporary objects (so that they can be reclaimed by the garbage collector) and otherwise returning the page to its pristine state. After detaching, a page is placed into the page pool, where it will await reuse for some future request (likely by a completely different user).</p>
-
-<p>As with <a shape="rect" href="component-rendering.html" title="Component Rendering">component rendering</a>, you have the ability to make your components "aware" of these events by identifying methods to be invoked.</p>
-
-<p>You have the choice of attaching an annotation to a method, or simply naming the method correctly.</p>
-
-<p>Page life cycle methods should take no parameters and return void.</p>
-
-<p>The annotations / method names are:</p>
-
-<ul><li>@<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/PageLoaded.html">PageLoaded</a> annotation, or method name "pageLoaded"</li><li>@<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/PageAttached.html">PageAttached</a> annotation, or method name "pageAttached"</li><li>@<a shape="rect" class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/PageDetached.html">PageDetached</a> annotation, or method name "pageDetached"</li></ul>
</div>
</div>