tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bobhar...@apache.org
Subject svn commit: r1018226 [5/41] - in /websites/production/tapestry/content: ./ cache/ styles/
Date Sat, 16 Sep 2017 01:54:20 GMT
Modified: websites/production/tapestry/content/component-cheat-sheet.html
==============================================================================
--- websites/production/tapestry/content/component-cheat-sheet.html (original)
+++ websites/production/tapestry/content/component-cheat-sheet.html Sat Sep 16 01:54:19 2017
@@ -27,6 +27,14 @@
       </title>
   <link type="text/css" rel="stylesheet" href="/resources/space.css" />
 
+          <link href='/resources/highlighter/styles/shCoreCXF.css' rel='stylesheet' type='text/css' />
+    <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' />
+    <script src='/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
+          <script src='/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
+        <script>
+      SyntaxHighlighter.defaults['toolbar'] = false;
+      SyntaxHighlighter.all();
+    </script>
   
   <link href="/styles/style.css" rel="stylesheet" type="text/css"/>
 
@@ -36,26 +44,13 @@
 
   <div class="wrapper bs">
 
-        <div id="navigation"><div class="nav"><ul class="alternate"><li><a  href="index.html">Home</a></li><li><a  href="getting-started.html">Getting Started</a></li><li><a  href="documentation.html">Documentation</a></li><li><a  href="download.html">Download</a></li><li><a  href="about.html">About</a></li><li><a  class="external-link" href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li><li><a  href="community.html">Community</a></li><li><a  class="external-link" href="http://www.apache.org/security/">Security</a></li><li><a  class="external-link" href="http://www.apache.org/">Apache</a></li><li><a  class="external-link" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a  class="external-link" href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></div>
-
-</div>
+        <div id="navigation"><div class="nav"><ul class="alternate"><li><a  href="index.html">Home</a></li><li><a  href="getting-started.html">Getting Started</a></li><li><a  href="documentation.html">Documentation</a></li><li><a  href="download.html">Download</a></li><li><a  href="about.html">About</a></li><li><a  class="external-link" href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li><li><a  href="community.html">Community</a></li><li><a  class="external-link" href="http://www.apache.org/security/">Security</a></li><li><a  class="external-link" href="http://www.apache.org/">Apache</a></li><li><a  class="external-link" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a  class="external-link" href="http://www.apache.org/foundation/thanks.html">Thanks</a></li></ul></div></div>
 
           <div id="top">
-            <div id="smallbanner"><div class="searchbox" style="float:right;margin: .3em 1em .1em 1em"><span style="color: #999; font-size: 90%">Tapestry docs, issues, wikis &amp; blogs:</span>
-<form enctype="application/x-www-form-urlencoded" method="get" action="http://tapestry.apache.org/search.html">
-  <input type="text" name="q">
-  <input type="submit" value="Search">
-</form>
-
-</div>
-
-
-<div class="emblem" style="float:left"><p><a  href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div>
-
-
-<div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">Component Cheat Sheet</h1></div>
-
-</div>
+            <div id="smallbanner"><div class="searchbox" style="float:right;margin: .3em 1em .1em 1em"><span style="color: #999; font-size: 90%">Tapestry docs, issues, wikis &amp; blogs:</span><form enctype="application/x-www-form-urlencoded" method="get" action="http://tapestry.apache.org/search.html"> 
+ <input type="text" name="q"> 
+ <input type="submit" value="Search"> 
+</form></div><div class="emblem" style="float:left"><p><a  href="index.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://tapestry.apache.org/images/tapestry_small.png" data-image-src="http://tapestry.apache.org/images/tapestry_small.png"></span></a></p></div><div class="title" style="float:left; margin: 0 0 0 3em"><h1 id="SmallBanner-PageTitle">Component Cheat Sheet</h1></div></div>
       <div class="clearer"></div>
       </div>
 
@@ -67,15 +62,67 @@
       </div>
 
       <div id="content">
-                <div id="ConfluenceContent"><p><parameter ac:name="hidden">true</parameter><parameter ac:name="atlassian-macro-output-type">INLINE</parameter><rich-text-body><p>the various annotations and methods you can add to Tapestry page and component classes</p></rich-text-body></p><p>&#160;</p><p>This is a summary of the more common annotations and methods you can add to Tapestry pages and component classes.</p><parameter ac:name="style">float:right</parameter><parameter ac:name="title">Related Articles</parameter><parameter ac:name="class">aui-label</parameter><rich-text-body><parameter ac:name="showLabels">false</parameter><parameter ac:name="showSpace">false</parameter><parameter ac:name="title">Related Articles</parameter><parameter ac:name="cql">label in ("component-classes","component-templates","components") and space = currentSpace()</parameter></rich-text-body><p>For an exhaustive list, see the <a  href="annotations.html">annotations list</a>.</p><h2 id="ComponentChea
 tSheet-FieldInjectionAnnotations">Field Injection Annotations</h2><p>Main articles: <a  href="component-classes.html">Component Classes</a>, <a  href="injection.html">Injection</a>, <a  href="annotations.html">Annotations</a></p><h3 id="ComponentCheatSheet-@Inject">@Inject</h3><p>@Inject is the Swiss Army knife of annotations; it's designed to connect your component to services, resources, and other objects. See <a  href="injection.html">Injection</a>.</p><h4 id="ComponentCheatSheet-ServiceInjection">Service Injection</h4><p>In most cases, the injected value is a service; the service is located by type. If there are ambiguities, caused by multiple services implementing the same interface, you'll see injection exceptions. You can resolve those exceptions by adding marker annotations to select a specific service, or by adding @Service to specify the specific service ID you want.</p><rich-text-body><p>Use of @Service is discouraged. If marker annotations are available, that is preferre
 d.</p></rich-text-body><h3 id="ComponentCheatSheet-@InjectComponent">@InjectComponent</h3><p>Injects a component from this component's template into this component's class. Injecting a component is based on the component's ID, which should match the field name. However, the value attribute of the @InjectComponent annotation can be specified as well, this takes precedence over the field name.</p><p>It is common to inject a component in order to obtain its client-side ID (used when generating client-side JavaScript).</p><h3 id="ComponentCheatSheet-@InjectContainer">@InjectContainer</h3><p>Injects the container of a component or, when used in a mixin, injects the component the mixin is attached to.</p><h3 id="ComponentCheatSheet-@InjectPage">@InjectPage</h3><p>Injects a page of the application. Normally, the page to inject is identified based on the field type. The value attribute can be specified, in which case the page to be injected is identified by name.</p><h3 id="ComponentCheatSh
 eet-@Environmental">@Environmental</h3><p>Injects an <a  href="environmental-services.html">environmental object</a>; such objects are request scoped but may be overridden at any time using the methods of the Environment service. Environmental objects are used to allow outer components to communicate with components they enclose.</p><p>Most often, @Environmental is used with type JavaScriptSupport, which is used to add JavaScript code and libraries to the rendered page.</p><h2 id="ComponentCheatSheet-FieldBehaviorAnnotations">Field Behavior Annotations</h2><p>Main articles: <a  href="component-classes.html">Component Classes</a>, <a  href="annotations.html">Annotations</a></p><h3 id="ComponentCheatSheet-@PageActivationContext">@PageActivationContext</h3><p>This annotation is allowed on a <em>single</em> field; the value of the field will be included in URLs for the page as the page's activation context. This is an alternative to implementing event handler methods<br clear="none"> fo
 r the activate and passivate events directly.</p><h3 id="ComponentCheatSheet-@Parameter">@Parameter</h3><p>Marks the field as a component parameter. Attributes of the annotation allow the parameter to be marked as required or optional. If the parameter value will typically be a literal string (for example, the title parameter to a Layout component), you should add <code>defaultPrefix=BindingConstants.LITERAL</code> to the annotation so that users of the component won't have to use the "literal:" binding prefix with the parameter. See <a  href="component-parameters.html">Component Parameters</a></p><h3 id="ComponentCheatSheet-@Persist">@Persist</h3><p>Marks the field as a persistent value, one that maintains its value between requests. The default <em>strategy</em> is to simply store the value in the session (which is created as needed). Other strategies can be specified by name as the value attribute. See <a  href="persistent-page-data.html">Persistent Page Data</a>.</p><h3 id="Comp
 onentCheatSheet-@Property">@Property</h3><p>Directs Tapestry to automatically generate a getter and a setter for the field, converting it to a JavaBeans property than can be referenced from the template.</p><h3 id="ComponentCheatSheet-@SessionState">@SessionState</h3><p>Marks the field as a Session State Object (SSO). SSOs store global data, and can be injected into any page or component. The SSOs are stored in the session, using a key based on the Java type. SSOs are usually created on demand, but the <code>create</code> attribute can turn this off. See <a  href="session-storage.html">Session Storage</a></p><h3 id="ComponentCheatSheet-@SessionAttribute">@SessionAttribute</h3><p>In Tapestry 5.2 and later, marks the field as a Session Attribute. Like Session State Objects (SSO), a Session Attribute is stored in the session, however Session Attributes are stored by using a name you choose rather than based on the Java type. See <a  href="session-storage.html">Session Storage</a>.</p><
 h3 id="ComponentCheatSheet-@ActivationRequestParameter">@ActivationRequestParameter</h3><p>Fields with this annotation will be encoded into URLs as query parameters, in much the same way as data is encoded into the URL path. The query parameter name matches the field name, unless the value attribute is specified.</p><h2 id="ComponentCheatSheet-MethodAnnotations">Method Annotations</h2><p>Main articles: <a  href="component-classes.html">Component Classes</a>, <a  href="annotations.html">Annotations</a></p><h3 id="ComponentCheatSheet-@OnEvent">@OnEvent</h3><p>Marks a method as an event handler method. Such methods may have any visibility, and typically use package private visibility (that is, no visibility keyword at all). By default, the method will handle the action event from any component; the value attribute controls the matched event, and the component annotation is used to limit the event source.</p><p>An event handler method may take parameters, corresponding the event context
  associated with the event, such as the page activation context for the activate event. The method will not be invoked if it defines more parameters than there are values in the context.</p><p>The @RequestParameter annotation can be used on parameters, in which case the parameters value comes from a request query parameter, and not from the event context.</p><p>Events fired on a component bubble up the component's container. Return a non-null value to cancel event bubbling. What values may be returned from an event handler method is dependent on the type of event.</p><p>You may also return true to indicate that the event is handled and bubbling should cancel (even for events that do not permit a return value).</p><rich-text-body><p>An alternative to @OnEvent is the naming convention <code>on</code><em>EventName</em> or <code>on</code><em>EventName</em><code>From</code><em>ComponentId</em>.</p></rich-text-body><h3 id="ComponentCheatSheet-@Log">@Log</h3><p>Marks the method to be logge
 d for debugging purposes: method entry (with parameters) and exit (with return value) will be logged at debug level, as will any thrown exception. This is primarily for debugging purposes. The Logger name will match the component classes' fully qualified class name.</p><h3 id="ComponentCheatSheet-@CommitAfter">@CommitAfter</h3><rich-text-body><p>The support for this annotation comes from the <a  href="hibernate.html">tapestry-hibernate</a> module or tapestry-jpa module.</p></rich-text-body><h3 id="ComponentCheatSheet-@Cached">@Cached</h3><p>Used on methods that perform expensive operations, such as database queries. The first time such a method is invoked, the return value is cached. Future invocations of the same method return the cached value.</p><p>The result cache is per-request and is discarded at the end of the request.</p><p>@Cached only works on methods that take no parameters.</p><h2 id="ComponentCheatSheet-ParameterAnnotations">Parameter Annotations</h2><p>Main article: <a
   href="component-parameters.html">Component Parameters</a></p><h3 id="ComponentCheatSheet-@RequestParameter">@RequestParameter</h3><p>Used with event handler methods to get the value for the parameter from a request query parameter.</p><h2 id="ComponentCheatSheet-TypeAnnotations">Type Annotations</h2><h3 id="ComponentCheatSheet-@Events">@Events</h3><p>Lists the names of events that may be fired from within this component; used for documentation purposes only.</p><h3 id="ComponentCheatSheet-@Import">@Import</h3><p>Allows JavaScript libraries and CSS stylesheet files to be included in the rendered page. Each such file is added to the page only once, in the order in which the page renders.</p><p>It is allowed to use symbol expansions (with the <code>${...</code>} syntax) inside a library or stylesheet path.</p><p>@Import may also be applied to individual methods, in which case the import operation only occurs when the method is invoked.</p><rich-text-body><p>When specifying a file to 
 import, you'll often use the prefix <code>context:</code> to indicate that the file is stored in the web application context, and not on the classpath. Relative paths will be on the classpath, relative to the Java class.</p></rich-text-body><h3 id="ComponentCheatSheet-@SupportsInformalParameters">@SupportsInformalParameters</h3><p>Marks the component as allowing informal parameters (extra attributes in the template that do not match formally declared parameters). Normally, informal parameters are simply discarded.</p><p>The method ComponentResources.renderInformalParameters() can be used to include the informal parameters within the element rendered by your component.</p><h3 id="ComponentCheatSheet-@Secure">@Secure</h3><p>Marks the page as accessible only via secure (HTTPs). Any attempt to access the page via standard HTTP will be redirected to the HTTPs version.</p><p>By default, the @Secure annotation is ignored in development mode and only active in production mode.</p><h2 id="Co
 mponentCheatSheet-RenderPhaseMethods">Render Phase Methods</h2><p>Main article: <a  href="component-rendering.html">Component Rendering</a></p><p>Render phase methods are close cousins to event handler methods; they are how Tapestry integrates your code into the overall rendering of the page. For each render phase, there's an annotation and corresponding naming convention to define a render phase method:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Annotation</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Method Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>General Use</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@SetupRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>setupRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Initializes the component before rendering</p></td></tr><tr><td colspan="1" rowspan="1" class="co
 nfluenceTd"><p>@BeginRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>beginRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Renders the element and primary attributes of the component</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@AfterRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>afterRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Closes the element started in beginRender()</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@CleanupRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>cleanupRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Performs cleanup after all rendering of the component finishes</p></td></tr></tbody></table></div><p>Render phase methods either take no parameters, or take a single parameter of type MarkupWriter.</p><p>Render phase methods may return <code>void</code>, a <code>boolean</code>, or a <em>rendera
 ble object</em>.</p><rich-text-body><p>Generally, a <code>renderable object</code> is a <a  class="external-link" href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/Block.html">Block</a> or a component. The object is pushed onto the stack of rendering operations, temporarily replacing the current component as the object to be rendered.</p></rich-text-body><p>Returning true is the same as returning void; it means that the component should follow the typical flow:</p><ul><li>@SetupRender</li><li>@BeginRender</li><li>Render the component's template, if any</li><li>Render the component's body</li><li>@AfterRender</li><li>@CleanupRender</li></ul><p>If a component has a template, the component's body will only render if the template contains a &lt;t:body&gt; element. If a component has no template, then it will always render its body (between @BeginRender and @AfterRender).</p><p>A render phase method may also return false, in which case the flow continues to an alternate r
 ender phase, as per the chart in the <a  href="component-rendering.html">Component Rendering</a> reference page.</p><p>The most common cases:</p><ul><li>return <code>false</code> from @BeginRender to skip the rendering of the component's template and/or body, and continue with @AfterRender</li><li>return <code>false</code> from @AfterRender to return to @BeginRender (this is used in component, such as <code>Loop</code>, that render themselves multiple times)</li></ul><h2 id="ComponentCheatSheet-PageLifeCycleMethods">Page Life Cycle Methods</h2><p>Main article: <a  href="page-life-cycle.html">Page Life Cycle</a></p><p>Pages have a life cycle and this is represented by a <em>third</em> set of annotations or method naming conventions. Life cycle methods may appear on a page or any component of a page.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Annotation</p></th><th colspan="1" rowspan="1" class="confluenceTh
 "><p>Method Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageLoaded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageLoaded()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The page instance has been loaded but not yet attached for the first time.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageAttached</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageAttached()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The page is being used within a particular request. This occurs before the activate event.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageReset</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageReset()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>See notes below.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageDetache
 d</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageDetached()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>End of request notification.</p></td></tr></tbody></table></div><p>Page life cycle methods may be any visibility. They must take no parameters and return void.</p><p>Page life cycle methods are of lower importance starting in Tapestry 5.2, since page instances are now shared across threads, rather than pooled.</p><p>The @PageReset life cycle is new in Tapestry 5.2. It will be invoked on a page render request when linked to from some other page of the application. This is to allow the page to reset its state, if any, when a user returns to the page from some other part of the application.</p><h2 id="ComponentCheatSheet-ConfiguringAnnotations">Configuring Annotations</h2><p>The SymbolProvider service has two interfaces : FactoryDefaults and ApplicationDefaults. Tapestry provides 2 annotations in order to define which implementation you want to overri
 de in your AppModule :&#160;</p><ul><li><p>@FactoryDefaults</p><parameter ac:name="title">AppModule with @FactoryDefaults</parameter><plain-text-body>@Contribute(SymbolProvider.class)
+                <div id="ConfluenceContent"><p>&#160;</p><p>This is a summary of the more common annotations and methods you can add to Tapestry pages and component classes.</p><div class="aui-label" style="float:right" title="Related Articles"><h3>Related Articles</h3><ul class="content-by-label"><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="component-parameters.html">Component Parameters</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="templating-and-markup-faq.html">Templating and Markup FAQ</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="component-classes.html">Component Classes</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="component-reference.html">Component Reference</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="component-libraries.html">Component Libraries</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="page-and-component-classes-faq.html">Page And Component Classes FAQ</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="component-templates.html">Component Templates</a> 
+  </div> </li><li> 
+  <div> 
+   <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span> 
+  </div> 
+  <div class="details"> 
+   <a  href="component-cheat-sheet.html">Component Cheat Sheet</a> 
+  </div> </li></ul></div><p>For an exhaustive list, see the <a  href="annotations.html">annotations list</a>.</p><h2 id="ComponentCheatSheet-FieldInjectionAnnotations">Field Injection Annotations</h2><p>Main articles: <a  href="component-classes.html">Component Classes</a>, <a  href="injection.html">Injection</a>, <a  href="annotations.html">Annotations</a></p><h3 id="ComponentCheatSheet-@Inject">@Inject</h3><p>@Inject is the Swiss Army knife of annotations; it's designed to connect your component to services, resources, and other objects. See <a  href="injection.html">Injection</a>.</p><h4 id="ComponentCheatSheet-ServiceInjection">Service Injection</h4><p>In most cases, the injected value is a service; the service is located by type. If there are ambiguities, caused by multiple services implementing the same interface, you'll see injection exceptions. You can resolve those exceptions by adding marker annotations to select a specific service, or by adding @Service to specify the spe
 cific service ID you want.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Use of @Service is discouraged. If marker annotations are available, that is preferred.</p></div></div><h3 id="ComponentCheatSheet-@InjectComponent">@InjectComponent</h3><p>Injects a component from this component's template into this component's class. Injecting a component is based on the component's ID, which should match the field name. However, the value attribute of the @InjectComponent annotation can be specified as well, this takes precedence over the field name.</p><p>It is common to inject a component in order to obtain its client-side ID (used when generating client-side JavaScript).</p><h3 id="ComponentCheatSheet-@InjectContainer">@InjectContainer</h3><p>Injects the container of a component or, when used in a mixin, inje
 cts the component the mixin is attached to.</p><h3 id="ComponentCheatSheet-@InjectPage">@InjectPage</h3><p>Injects a page of the application. Normally, the page to inject is identified based on the field type. The value attribute can be specified, in which case the page to be injected is identified by name.</p><h3 id="ComponentCheatSheet-@Environmental">@Environmental</h3><p>Injects an <a  href="environmental-services.html">environmental object</a>; such objects are request scoped but may be overridden at any time using the methods of the Environment service. Environmental objects are used to allow outer components to communicate with components they enclose.</p><p>Most often, @Environmental is used with type JavaScriptSupport, which is used to add JavaScript code and libraries to the rendered page.</p><h2 id="ComponentCheatSheet-FieldBehaviorAnnotations">Field Behavior Annotations</h2><p>Main articles: <a  href="component-classes.html">Component Classes</a>, <a  href="annotations.h
 tml">Annotations</a></p><h3 id="ComponentCheatSheet-@PageActivationContext">@PageActivationContext</h3><p>This annotation is allowed on a <em>single</em> field; the value of the field will be included in URLs for the page as the page's activation context. This is an alternative to implementing event handler methods<br clear="none"> for the activate and passivate events directly.</p><h3 id="ComponentCheatSheet-@Parameter">@Parameter</h3><p>Marks the field as a component parameter. Attributes of the annotation allow the parameter to be marked as required or optional. If the parameter value will typically be a literal string (for example, the title parameter to a Layout component), you should add <code>defaultPrefix=BindingConstants.LITERAL</code> to the annotation so that users of the component won't have to use the "literal:" binding prefix with the parameter. See <a  href="component-parameters.html">Component Parameters</a></p><h3 id="ComponentCheatSheet-@Persist">@Persist</h3><p>Ma
 rks the field as a persistent value, one that maintains its value between requests. The default <em>strategy</em> is to simply store the value in the session (which is created as needed). Other strategies can be specified by name as the value attribute. See <a  href="persistent-page-data.html">Persistent Page Data</a>.</p><h3 id="ComponentCheatSheet-@Property">@Property</h3><p>Directs Tapestry to automatically generate a getter and a setter for the field, converting it to a JavaBeans property than can be referenced from the template.</p><h3 id="ComponentCheatSheet-@SessionState">@SessionState</h3><p>Marks the field as a Session State Object (SSO). SSOs store global data, and can be injected into any page or component. The SSOs are stored in the session, using a key based on the Java type. SSOs are usually created on demand, but the <code>create</code> attribute can turn this off. See <a  href="session-storage.html">Session Storage</a></p><h3 id="ComponentCheatSheet-@SessionAttribute
 ">@SessionAttribute</h3><p>In Tapestry 5.2 and later, marks the field as a Session Attribute. Like Session State Objects (SSO), a Session Attribute is stored in the session, however Session Attributes are stored by using a name you choose rather than based on the Java type. See <a  href="session-storage.html">Session Storage</a>.</p><h3 id="ComponentCheatSheet-@ActivationRequestParameter">@ActivationRequestParameter</h3><p>Fields with this annotation will be encoded into URLs as query parameters, in much the same way as data is encoded into the URL path. The query parameter name matches the field name, unless the value attribute is specified.</p><h2 id="ComponentCheatSheet-MethodAnnotations">Method Annotations</h2><p>Main articles: <a  href="component-classes.html">Component Classes</a>, <a  href="annotations.html">Annotations</a></p><h3 id="ComponentCheatSheet-@OnEvent">@OnEvent</h3><p>Marks a method as an event handler method. Such methods may have any visibility, and typically us
 e package private visibility (that is, no visibility keyword at all). By default, the method will handle the action event from any component; the value attribute controls the matched event, and the component annotation is used to limit the event source.</p><p>An event handler method may take parameters, corresponding the event context associated with the event, such as the page activation context for the activate event. The method will not be invoked if it defines more parameters than there are values in the context.</p><p>The @RequestParameter annotation can be used on parameters, in which case the parameters value comes from a request query parameter, and not from the event context.</p><p>Events fired on a component bubble up the component's container. Return a non-null value to cancel event bubbling. What values may be returned from an event handler method is dependent on the type of event.</p><p>You may also return true to indicate that the event is handled and bubbling should c
 ancel (even for events that do not permit a return value).</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>An alternative to @OnEvent is the naming convention <code>on</code><em>EventName</em> or <code>on</code><em>EventName</em><code>From</code><em>ComponentId</em>.</p></div></div><h3 id="ComponentCheatSheet-@Log">@Log</h3><p>Marks the method to be logged for debugging purposes: method entry (with parameters) and exit (with return value) will be logged at debug level, as will any thrown exception. This is primarily for debugging purposes. The Logger name will match the component classes' fully qualified class name.</p><h3 id="ComponentCheatSheet-@CommitAfter">@CommitAfter</h3><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warn
 ing confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The support for this annotation comes from the <a  href="hibernate.html">tapestry-hibernate</a> module or tapestry-jpa module.</p></div></div><h3 id="ComponentCheatSheet-@Cached">@Cached</h3><p>Used on methods that perform expensive operations, such as database queries. The first time such a method is invoked, the return value is cached. Future invocations of the same method return the cached value.</p><p>The result cache is per-request and is discarded at the end of the request.</p><p>@Cached only works on methods that take no parameters.</p><h2 id="ComponentCheatSheet-ParameterAnnotations">Parameter Annotations</h2><p>Main article: <a  href="component-parameters.html">Component Parameters</a></p><h3 id="ComponentCheatSheet-@RequestParameter">@RequestParameter</h3><p>Used with event handler methods to get the value for the parameter from a request query parameter.</p><h2 id="ComponentChe
 atSheet-TypeAnnotations">Type Annotations</h2><h3 id="ComponentCheatSheet-@Events">@Events</h3><p>Lists the names of events that may be fired from within this component; used for documentation purposes only.</p><h3 id="ComponentCheatSheet-@Import">@Import</h3><p>Allows JavaScript libraries and CSS stylesheet files to be included in the rendered page. Each such file is added to the page only once, in the order in which the page renders.</p><p>It is allowed to use symbol expansions (with the <code>${...</code>} syntax) inside a library or stylesheet path.</p><p>@Import may also be applied to individual methods, in which case the import operation only occurs when the method is invoked.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When specifying a file to import, you'll often use the prefix <code>context:
 </code> to indicate that the file is stored in the web application context, and not on the classpath. Relative paths will be on the classpath, relative to the Java class.</p></div></div><h3 id="ComponentCheatSheet-@SupportsInformalParameters">@SupportsInformalParameters</h3><p>Marks the component as allowing informal parameters (extra attributes in the template that do not match formally declared parameters). Normally, informal parameters are simply discarded.</p><p>The method ComponentResources.renderInformalParameters() can be used to include the informal parameters within the element rendered by your component.</p><h3 id="ComponentCheatSheet-@Secure">@Secure</h3><p>Marks the page as accessible only via secure (HTTPs). Any attempt to access the page via standard HTTP will be redirected to the HTTPs version.</p><p>By default, the @Secure annotation is ignored in development mode and only active in production mode.</p><h2 id="ComponentCheatSheet-RenderPhaseMethods">Render Phase Meth
 ods</h2><p>Main article: <a  href="component-rendering.html">Component Rendering</a></p><p>Render phase methods are close cousins to event handler methods; they are how Tapestry integrates your code into the overall rendering of the page. For each render phase, there's an annotation and corresponding naming convention to define a render phase method:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Annotation</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Method Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>General Use</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@SetupRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>setupRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Initializes the component before rendering</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@BeginRender</p></td><td colspan="1" row
 span="1" class="confluenceTd"><p>beginRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Renders the element and primary attributes of the component</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@AfterRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>afterRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Closes the element started in beginRender()</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@CleanupRender</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>cleanupRender()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Performs cleanup after all rendering of the component finishes</p></td></tr></tbody></table></div><p>Render phase methods either take no parameters, or take a single parameter of type MarkupWriter.</p><p>Render phase methods may return <code>void</code>, a <code>boolean</code>, or a <em>renderable object</em>.</p><div class="confluence-information-
 macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Generally, a <code>renderable object</code> is a <a  class="external-link" href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/Block.html">Block</a> or a component. The object is pushed onto the stack of rendering operations, temporarily replacing the current component as the object to be rendered.</p></div></div><p>Returning true is the same as returning void; it means that the component should follow the typical flow:</p><ul><li>@SetupRender</li><li>@BeginRender</li><li>Render the component's template, if any</li><li>Render the component's body</li><li>@AfterRender</li><li>@CleanupRender</li></ul><p>If a component has a template, the component's body will only render if the template contains a &lt;t:body&gt; element. If a component has no template, then it will always render its 
 body (between @BeginRender and @AfterRender).</p><p>A render phase method may also return false, in which case the flow continues to an alternate render phase, as per the chart in the <a  href="component-rendering.html">Component Rendering</a> reference page.</p><p>The most common cases:</p><ul><li>return <code>false</code> from @BeginRender to skip the rendering of the component's template and/or body, and continue with @AfterRender</li><li>return <code>false</code> from @AfterRender to return to @BeginRender (this is used in component, such as <code>Loop</code>, that render themselves multiple times)</li></ul><h2 id="ComponentCheatSheet-PageLifeCycleMethods">Page Life Cycle Methods</h2><p>Main article: <a  href="page-life-cycle.html">Page Life Cycle</a></p><p>Pages have a life cycle and this is represented by a <em>third</em> set of annotations or method naming conventions. Life cycle methods may appear on a page or any component of a page.</p><div class="table-wrap"><table class=
 "confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Annotation</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Method Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageLoaded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageLoaded()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The page instance has been loaded but not yet attached for the first time.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageAttached</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageAttached()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The page is being used within a particular request. This occurs before the activate event.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageReset</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageReset()</p></td><td
  colspan="1" rowspan="1" class="confluenceTd"><p>See notes below.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>@PageDetached</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>pageDetached()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>End of request notification.</p></td></tr></tbody></table></div><p>Page life cycle methods may be any visibility. They must take no parameters and return void.</p><p>Page life cycle methods are of lower importance starting in Tapestry 5.2, since page instances are now shared across threads, rather than pooled.</p><p>The @PageReset life cycle is new in Tapestry 5.2. It will be invoked on a page render request when linked to from some other page of the application. This is to allow the page to reset its state, if any, when a user returns to the page from some other part of the application.</p><h2 id="ComponentCheatSheet-ConfiguringAnnotations">Configuring Annotations</h2><p>The SymbolProvider service has t
 wo interfaces : FactoryDefaults and ApplicationDefaults. Tapestry provides 2 annotations in order to define which implementation you want to override in your AppModule :&#160;</p><ul><li><p>@FactoryDefaults</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule with @FactoryDefaults</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@Contribute(SymbolProvider.class)
 @FactoryDefaults
 public void setParam(MappedConfiguration&lt; String, String&gt; configuration){
   configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
-}</plain-text-body></li><li><p>@ApplicationDefaults</p><parameter ac:name="title">AppModule with @ApplicationDefaults</parameter><plain-text-body>@Contribute(SymbolProvider.class)
+}</pre>
+</div></div></li><li><p>@ApplicationDefaults</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>AppModule with @ApplicationDefaults</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@Contribute(SymbolProvider.class)
 @ApplicationDefaults
 public void setParam(MappedConfiguration&lt; String, String&gt; configuration){
   configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
-}</plain-text-body></li></ul><p>&#160;</p><p></p></div>
+}</pre>
+</div></div></li></ul><p>&#160;</p><p></p></div>
       </div>
 
       <div class="clearer"></div>

Modified: websites/production/tapestry/content/component-classes.html
==============================================================================
--- websites/production/tapestry/content/component-classes.html (original)
+++ websites/production/tapestry/content/component-classes.html Sat Sep 16 01:54:19 2017
@@ -27,6 +27,15 @@
       </title>
   <link type="text/css" rel="stylesheet" href="/resources/space.css" />
 
+          <link href='/resources/highlighter/styles/shCoreCXF.css' rel='stylesheet' type='text/css' />
+    <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' />
+    <script src='/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
+          <script src='/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
+          <script src='/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
+        <script>
+      SyntaxHighlighter.defaults['toolbar'] = false;
+      SyntaxHighlighter.all();
+    </script>
   
   <link href="/styles/style.css" rel="stylesheet" type="text/css"/>
 
@@ -67,14 +76,88 @@
       </div>
 
       <div id="content">
-                <div id="ConfluenceContent"><p>A <strong>component class</strong>&#160;is the class associated with a page, component or mixin in your Tapestry web application. Classes for pages, components and mixins are all created in an identical way. They are pure POJOs (Plain Old Java Objects), typically with annotations and conventionally named methods. They are not <em>abstract</em>, nor do they need to extend base classes or implement interfaces.</p><parameter ac:name="style">float:right</parameter><parameter ac:name="title">Related Articles</parameter><parameter ac:name="class">aui-label</parameter><rich-text-body><parameter ac:name="showLabels">false</parameter><parameter ac:name="showSpace">false</parameter><parameter ac:name="title">Related Articles</parameter><parameter ac:name="cql">label in ("component-classes","components") and space = currentSpace()</parameter></rich-text-body><p>In most cases, each component class will have a corresponding <a  href="component-templ
 ates.html">component template</a>. However, it is also possible for a component class to emit all of its markup itself, without using a template.</p><p><em>For Tapestry 4 Users: Component classes in Tapestry 5 are much easier than in Tapestry 4. There are no base classes to extend from, the classes are concrete (not abstract), and there's no XML file. There is still a bit of configuration in the form of Java annotations, but those now go directly onto fields of your class, rather than on abstract getters and setters.</em></p><h2 id="ComponentClasses-CreatingaTrivialComponent">Creating a Trivial Component</h2><p>Creating a page or component in Tapestry 5 is a breeze. There are only a few constraints:</p><ul><li>There must be a public Java class.</li><li>The class must be in the correct package (see below).</li><li>The class must have a public, no-arguments constructor. (The default one provided by the compiler is fine.)</li></ul><p>Here's a minimal component that outputs a fixed mess
 age, using a <a  href="component-templates.html">template</a> with a matching file name:</p><rich-text-body><rich-text-body><parameter ac:name="language">java</parameter><parameter ac:name="title">HelloWorld.java</parameter><plain-text-body>package org.example.myapp.components;
+                <div id="ConfluenceContent"><p>A <strong>component class</strong>&#160;is the class associated with a page, component or mixin in your Tapestry web application. Classes for pages, components and mixins are all created in an identical way. They are pure POJOs (Plain Old Java Objects), typically with annotations and conventionally named methods. They are not <em>abstract</em>, nor do they need to extend base classes or implement interfaces.</p><div class="aui-label" style="float:right" title="Related Articles">
+
+
+
+
+
+
+
+
+<h3>Related Articles</h3>
+
+<ul class="content-by-label"><li>
+        <div>
+                <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span>        </div>
+
+        <div class="details">
+                        <a  href="component-reference.html">Component Reference</a>
+                
+                        
+                    </div>
+    </li><li>
+        <div>
+                <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span>        </div>
+
+        <div class="details">
+                        <a  href="component-libraries.html">Component Libraries</a>
+                
+                        
+                    </div>
+    </li><li>
+        <div>
+                <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span>        </div>
+
+        <div class="details">
+                        <a  href="page-and-component-classes-faq.html">Page And Component Classes FAQ</a>
+                
+                        
+                    </div>
+    </li><li>
+        <div>
+                <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span>        </div>
+
+        <div class="details">
+                        <a  href="component-templates.html">Component Templates</a>
+                
+                        
+                    </div>
+    </li><li>
+        <div>
+                <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span>        </div>
+
+        <div class="details">
+                        <a  href="component-cheat-sheet.html">Component Cheat Sheet</a>
+                
+                        
+                    </div>
+    </li><li>
+        <div>
+                <span class="icon aui-icon aui-icon-small aui-iconfont-page-default" title="Page">Page:</span>        </div>
+
+        <div class="details">
+                        <a  href="component-parameters.html">Component Parameters</a>
+                
+                        
+                    </div>
+    </li></ul>
+</div>
+
+
+<p>In most cases, each component class will have a corresponding <a  href="component-templates.html">component template</a>. However, it is also possible for a component class to emit all of its markup itself, without using a template.</p><p><em>For Tapestry 4 Users: Component classes in Tapestry 5 are much easier than in Tapestry 4. There are no base classes to extend from, the classes are concrete (not abstract), and there's no XML file. There is still a bit of configuration in the form of Java annotations, but those now go directly onto fields of your class, rather than on abstract getters and setters.</em></p><h2 id="ComponentClasses-CreatingaTrivialComponent">Creating a Trivial Component</h2><p>Creating a page or component in Tapestry 5 is a breeze. There are only a few constraints:</p><ul><li>There must be a public Java class.</li><li>The class must be in the correct package (see below).</li><li>The class must have a public, no-arguments constructor. (The default one provided 
 by the compiler is fine.)</li></ul><p>Here's a minimal component that outputs a fixed message, using a <a  href="component-templates.html">template</a> with a matching file name:</p><div class="sectionColumnWrapper"><div class="sectionMacro"><div class="sectionMacroRow"><div class="columnMacro"><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>HelloWorld.java</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">package org.example.myapp.components;
 public class HelloWorld
 {
 }
-</plain-text-body></rich-text-body><rich-text-body><parameter ac:name="language">xml</parameter><parameter ac:name="title">HelloWorld.tml</parameter><plain-text-body>&lt;html&gt;
+</pre>
+</div></div></div><div class="columnMacro"><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>HelloWorld.tml</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;html&gt;
     Bonjour from HelloWorld component.
 &lt;/html&gt;
-</plain-text-body></rich-text-body></rich-text-body><p>In the example above, the HelloWorld class contains no code at all (except what it inherits from the Object class and what Tapestry adds invisibly).</p><p>And here's a component that does the same thing, but without needing a template:</p><parameter ac:name="language">java</parameter><parameter ac:name="title">HelloWorld.java -- without a template</parameter><plain-text-body>package org.example.myapp.components;
+</pre>
+</div></div></div></div></div></div><p>In the example above, the HelloWorld class contains no code at all (except what it inherits from the Object class and what Tapestry adds invisibly).</p><p>And here's a component that does the same thing, but without needing a template:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>HelloWorld.java &#8211; without a template</b></div><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">package org.example.myapp.components;
 
 import org.apache.tapestry5.MarkupWriter;
 import org.apache.tapestry5.annotations.BeginRender;
@@ -87,13 +170,15 @@ public class HelloWorld
         writer.write("Bonjour from HelloWorld component.");
     }
 }
-</plain-text-body><p>In this example, just like the first one, the component's only job is to write out a fixed message. The @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/BeginRender.html">BeginRender</a> annotation is a type of <em><a  href="component-rendering.html">render phase annotation</a></em>, a method annotation that instructs Tapestry when and under what circumstances to invoke methods of your class.</p><p>These methods are not necessarily public; they can have any access level you like (unlike in Tapestry 4). By convention they usually have package-private access level (the default).</p><h2 id="ComponentClasses-ComponentPackages">Component Packages</h2><p>Component classes must exist within an appropriate package (this is necessary for runtime code transformation and class reloading to operate).</p><p>These packages exist under the application's root package, as follows:</p><ul><li>For pages, place classes in 
 <em>root</em>.<strong>pages</strong>. Page names are mapped to classes within this package.</li><li>For mixins, place classes in <em>root</em>.<strong>mixins</strong>. Mixin types are mapped to classes within this package.</li><li>For other components, place classes in <em>root</em>.<strong>components</strong>. Component types are mapped to classes within this package.</li></ul><p>In addition, it is common for an application to have base classes, often <em>abstract</em> base classes, that should not be directly referenced. These should <em>not</em> go in the <strong>pages</strong>, <strong>components</strong> or <strong>mixins</strong> packages, because they then look like valid pages, components or mixins. Instead, use the <em>root</em>.<strong>base</strong> package to store such base classes.</p><rich-text-body><p>Only component classes should go in any of these controlled packages; classes representing data, or interfaces, or anything that isn't precisely a component class, must 
 go elsewhere. Any top-level class in any of the controlled packages will be transformed at runtime. The only exception is inner classes (anonymous or not), which are loaded by the same class loader as the component class loader, but not transformed as components.</p></rich-text-body><h2 id="ComponentClasses-Sub-Folders/Sub-Packages">Sub-Folders / Sub-Packages</h2><p>Classes do not have to go directly inside the package (pages, components, mixins, etc.). It is valid to create a sub-package to store some of the classes. The sub-package name becomes part of the page name or component type. Thus you might define a page component <code>com.example.myapp.pages.admin.CreateUser</code> and the logical page name (which often shows up inside URLs) will be <strong>admin/CreateUser</strong>.</p><p>Tapestry performs some simple optimizations of the logical page name (or component type, or mixin type). It checks to see if the package name is either a prefix or a suffix of the unqualified class na
 me (case insensitively, of course) and removes the prefix or suffix if so. The net result is that a class name such as <code>com.example.myapp.pages.user.EditUser</code> will have a page name of <code>user/Edit</code> (instead of user<code>/EditUser</code>). The goal here is to provide shorter, more natural URLs.</p><h2 id="ComponentClasses-IndexPages">Index Pages</h2><p>One special simplification exists for Index pages: if the logical page name is Index after removing the package name from the unqualified class name, it will map to the root of that folder. A class such as <code>com.example.myapp.pages.user.IndexUser</code> or <code>com.example.myapp.pages.user.UserIndex</code> will have a page name of <code>user/</code>.</p><p>In previous versions of Tapestry there was also the concept of a start page configured with the <code><a  href="configuration.html">tapestry.start-page-name</a></code> configuration symbol (defaults to "start"). If a page with a name as configured with that s
 ymbol exists at the root level, this page is used as the root URL. This has precedence over an existing Index page. If for example you have a page class <code>com.example.myapp.pages.Start</code> it will map to <code>/</code>.</p><rich-text-body><p>Use of start-pages is discouraged and support for it will eventually be removed. Use an Index page instead.</p></rich-text-body><h2 id="ComponentClasses-Pagesvs.Components">Pages vs. Components</h2><p>The distinction between pages and component is very, very small. The primary difference is the package name: <em>root</em>.<strong>pages</strong>.<em>PageName</em> for pages, and <em>root</em>.<strong>components</strong>.<em>ComponentType</em> for components. Conceptually, page components are simply the <em>root component</em> of a page's component tree.</p><p><em>For Tapestry 4 users: there was a much greater distinction in Tapestry 4 between pages and components, which showed up as separate interfaces and a hierarchy of abstract implementa
 tions to extend your classes from.</em></p><h2 id="ComponentClasses-ClassTransformation">Class Transformation</h2><p>Tapestry uses your class as a starting point. It <em>transforms</em> your class at runtime. This is necessary for a number of reasons, including to address how Tapestry shares pages between requests.</p><p>For the most part, these transformations are both sensible and invisible. In a few limited cases, they comprise a marginally&#160;<a  class="external-link" href="http://www.joelonsoftware.com/printerFriendly/articles/LeakyAbstractions.html" rel="nofollow">leaky abstraction</a>&#160;&#8211; for instance, the scope restrictions on instance variables described below &#8211; but the programming model in general supports a very high level of developer productivity.</p><p>Because transformation doesn't occur until <em>runtime</em>, the build stage of your application is not affected by the fact that you are creating a Tapestry application. Further, your classes are absolu
 tely simple POJOs during unit testing.</p><h2 id="ComponentClasses-LiveClassReloading">Live Class Reloading</h2><p>Main Article: <a  href="class-reloading.html">Class Reloading</a></p><p>Component classes are monitored for changes by the framework. <a  href="class-reloading.html">Classes are reloaded when changed</a>. This allows you to build your application with a speed approaching that of a scripting environment, without sacrificing any of the power of the Java platform.</p><p>And it's fast! You won't even notice that this magic class reloading has occurred.</p><p>The net result: super productivity &#8212; change your class, see the change instantly. This is designed to be a blend of the best of scripting environments (such as Python or Ruby) with all the speed and power of Java backing it up.</p><p>However, class reloading <em>only</em> applies to component classes (pages, components and mixins) and, starting in 5.2, Tapestry IOC-based service implementations (with some restrict
 ions). Other classes, such as service interfaces, entity/model classes, and other data objects, are loaded by the normal class loader and not subject to live class reloading.</p><h2 id="ComponentClasses-InstanceVariables">Instance Variables</h2><p>Tapestry components may have instance variables (unlike Tapestry 4, where you had to use <em>abstract properties</em>).</p><p>Since release 5.3.2, instance variables may be protected, or package private (that is, no access modifier). Under specific circumstances they may even be public (public fields must either be final, or have the @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Retain.html">Retain</a>&#160;annotation).</p><p><span style="line-height: 1.4285715;">Be aware that you will need to either provide getter and setter methods to access your classes' instance variables, or else annotate the fields with</span><span style="line-height: 1.4285715;">&#160;@</span><a  class="
 external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Property.html" style="line-height: 1.4285715;">Property</a>.</p><h2 id="ComponentClasses-TransientInstanceVariables">Transient Instance Variables</h2><p>Unless an instance variable is decorated with an annotation, it will be a <em>transient</em> instance variable. This means that its value resets to its default value at the end of reach request (when the <a  href="page-life-cycle.html">page is detached from the request</a>).</p><parameter ac:name="title">About initialization</parameter><rich-text-body><p>Never initialize an instance field to a <em>mutable</em> object at the point of declaration. If this is done, the instance created from that initializer becomes the default value for that field and is reused inside the component on every request. This could cause state to inadvertently be shared between different sessions in an application.</p></rich-text-body>
+</pre>
+</div></div><p>In this example, just like the first one, the component's only job is to write out a fixed message. The @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/BeginRender.html">BeginRender</a> annotation is a type of <em><a  href="component-rendering.html">render phase annotation</a></em>, a method annotation that instructs Tapestry when and under what circumstances to invoke methods of your class.</p><p>These methods are not necessarily public; they can have any access level you like (unlike in Tapestry 4). By convention they usually have package-private access level (the default).</p><h2 id="ComponentClasses-ComponentPackages">Component Packages</h2><p>Component classes must exist within an appropriate package (this is necessary for runtime code transformation and class reloading to operate).</p><p>These packages exist under the application's root package, as follows:</p><ul><li>For pages, place classes in <em>ro
 ot</em>.<strong>pages</strong>. Page names are mapped to classes within this package.</li><li>For mixins, place classes in <em>root</em>.<strong>mixins</strong>. Mixin types are mapped to classes within this package.</li><li>For other components, place classes in <em>root</em>.<strong>components</strong>. Component types are mapped to classes within this package.</li></ul><p>In addition, it is common for an application to have base classes, often <em>abstract</em> base classes, that should not be directly referenced. These should <em>not</em> go in the <strong>pages</strong>, <strong>components</strong> or <strong>mixins</strong> packages, because they then look like valid pages, components or mixins. Instead, use the <em>root</em>.<strong>base</strong> package to store such base classes.</p><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confl
 uence-information-macro-body"><p>Only component classes should go in any of these controlled packages; classes representing data, or interfaces, or anything that isn't precisely a component class, must go elsewhere. Any top-level class in any of the controlled packages will be transformed at runtime. The only exception is inner classes (anonymous or not), which are loaded by the same class loader as the component class loader, but not transformed as components.</p></div></div><h2 id="ComponentClasses-Sub-Folders/Sub-Packages">Sub-Folders / Sub-Packages</h2><p>Classes do not have to go directly inside the package (pages, components, mixins, etc.). It is valid to create a sub-package to store some of the classes. The sub-package name becomes part of the page name or component type. Thus you might define a page component <code>com.example.myapp.pages.admin.CreateUser</code> and the logical page name (which often shows up inside URLs) will be <strong>admin/CreateUser</strong>.</p><p>Tap
 estry performs some simple optimizations of the logical page name (or component type, or mixin type). It checks to see if the package name is either a prefix or a suffix of the unqualified class name (case insensitively, of course) and removes the prefix or suffix if so. The net result is that a class name such as <code>com.example.myapp.pages.user.EditUser</code> will have a page name of <code>user/Edit</code> (instead of user<code>/EditUser</code>). The goal here is to provide shorter, more natural URLs.</p><h2 id="ComponentClasses-IndexPages">Index Pages</h2><p>One special simplification exists for Index pages: if the logical page name is Index after removing the package name from the unqualified class name, it will map to the root of that folder. A class such as <code>com.example.myapp.pages.user.IndexUser</code> or <code>com.example.myapp.pages.user.UserIndex</code> will have a page name of <code>user/</code>.</p><p>In previous versions of Tapestry there was also the concept of
  a start page configured with the <code><a  href="configuration.html">tapestry.start-page-name</a></code> configuration symbol (defaults to "start"). If a page with a name as configured with that symbol exists at the root level, this page is used as the root URL. This has precedence over an existing Index page. If for example you have a page class <code>com.example.myapp.pages.Start</code> it will map to <code>/</code>.</p><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Use of start-pages is discouraged and support for it will eventually be removed. Use an Index page instead.</p></div></div><h2 id="ComponentClasses-Pagesvs.Components">Pages vs. Components</h2><p>The distinction between pages and component is very, very small. The primary difference is the package name: <em>root</em>.<strong>pages</strong>.<
 em>PageName</em> for pages, and <em>root</em>.<strong>components</strong>.<em>ComponentType</em> for components. Conceptually, page components are simply the <em>root component</em> of a page's component tree.</p><p><em>For Tapestry 4 users: there was a much greater distinction in Tapestry 4 between pages and components, which showed up as separate interfaces and a hierarchy of abstract implementations to extend your classes from.</em></p><h2 id="ComponentClasses-ClassTransformation">Class Transformation</h2><p>Tapestry uses your class as a starting point. It <em>transforms</em> your class at runtime. This is necessary for a number of reasons, including to address how Tapestry shares pages between requests.</p><p>For the most part, these transformations are both sensible and invisible. In a few limited cases, they comprise a marginally&#160;<a  class="external-link" href="http://www.joelonsoftware.com/printerFriendly/articles/LeakyAbstractions.html" rel="nofollow">leaky abstraction<
 /a>&#160;&#8211; for instance, the scope restrictions on instance variables described below &#8211; but the programming model in general supports a very high level of developer productivity.</p><p>Because transformation doesn't occur until <em>runtime</em>, the build stage of your application is not affected by the fact that you are creating a Tapestry application. Further, your classes are absolutely simple POJOs during unit testing.</p><h2 id="ComponentClasses-LiveClassReloading">Live Class Reloading</h2><p>Main Article: <a  href="class-reloading.html">Class Reloading</a></p><p>Component classes are monitored for changes by the framework. <a  href="class-reloading.html">Classes are reloaded when changed</a>. This allows you to build your application with a speed approaching that of a scripting environment, without sacrificing any of the power of the Java platform.</p><p>And it's fast! You won't even notice that this magic class reloading has occurred.</p><p>The net result: super p
 roductivity &#8212; change your class, see the change instantly. This is designed to be a blend of the best of scripting environments (such as Python or Ruby) with all the speed and power of Java backing it up.</p><p>However, class reloading <em>only</em> applies to component classes (pages, components and mixins) and, starting in 5.2, Tapestry IOC-based service implementations (with some restrictions). Other classes, such as service interfaces, entity/model classes, and other data objects, are loaded by the normal class loader and not subject to live class reloading.</p><h2 id="ComponentClasses-InstanceVariables">Instance Variables</h2><p>Tapestry components may have instance variables (unlike Tapestry 4, where you had to use <em>abstract properties</em>).</p><p>Since release 5.3.2, instance variables may be protected, or package private (that is, no access modifier). Under specific circumstances they may even be public (public fields must either be final, or have the @<a  class="e
 xternal-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Retain.html">Retain</a>&#160;annotation).</p><p><span style="line-height: 1.4285715;">Be aware that you will need to either provide getter and setter methods to access your classes' instance variables, or else annotate the fields with</span><span style="line-height: 1.4285715;">&#160;@</span><a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Property.html" style="line-height: 1.4285715;">Property</a>.</p><h2 id="ComponentClasses-TransientInstanceVariables">Transient Instance Variables</h2><p>Unless an instance variable is decorated with an annotation, it will be a <em>transient</em> instance variable. This means that its value resets to its default value at the end of reach request (when the <a  href="page-life-cycle.html">page is detached from the request</a>).</p><div class="confluence-information-macro confluence-information-macr
 o-note"><p class="title">About initialization</p><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Never initialize an instance field to a <em>mutable</em> object at the point of declaration. If this is done, the instance created from that initializer becomes the default value for that field and is reused inside the component on every request. This could cause state to inadvertently be shared between different sessions in an application.</p></div></div>
 
 <div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Deprecated since 5.2</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body">
 </div></div>
 <div class="error"><span class="error">Unknown macro: {div}</span> 
 <p>For Tapestry 5.1 and earlier, in the rare event that you have a variable that can keep its value between requests and you would like to defeat that reset logic, then you can add a @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Retain.html">Retain</a> annotation to the field. You should take care that no client-specific data is stored into such a field, since on a later request the same page <em>instance</em> may be used for a different user. Likewise, on a later request for the <em>same</em> client, a <em>different</em> page instance may be used.</p>
-</div><p>Use <a  href="persistent-page-data.html">persistent fields</a> to hold client-specific information from one request to the next.</p><p>Further, final fields are (in fact) final, and will not be reset between requests.</p><h2 id="ComponentClasses-Constructors">Constructors</h2><p>Tapestry will instantiate your class using the default, no arguments constructor. Other constructors will be ignored.</p><h2 id="ComponentClasses-Injection">Injection</h2><p>Main Article: <a  href="injection.html">Injection</a></p><p>Injection of dependencies occurs at the field level, via additional annotations. At runtime, fields that contain injections become read-only.</p><parameter ac:name="language">java</parameter><plain-text-body>@Inject // inject a resource
+</div><p>Use <a  href="persistent-page-data.html">persistent fields</a> to hold client-specific information from one request to the next.</p><p>Further, final fields are (in fact) final, and will not be reset between requests.</p><h2 id="ComponentClasses-Constructors">Constructors</h2><p>Tapestry will instantiate your class using the default, no arguments constructor. Other constructors will be ignored.</p><h2 id="ComponentClasses-Injection">Injection</h2><p>Main Article: <a  href="injection.html">Injection</a></p><p>Injection of dependencies occurs at the field level, via additional annotations. At runtime, fields that contain injections become read-only.</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;">@Inject // inject a resource
 private ComponentResources componentResources;
 
 @Inject // inject a block
@@ -105,7 +190,9 @@ private Asset banner;
 
 @Inject // inject a service
 private AjaxResponseRenderer ajaxResponseRenderer;
-</plain-text-body><h2 id="ComponentClasses-Parameters">Parameters</h2><p>Main Article: <a  href="component-parameters.html">Component Parameters</a></p><p>Component parameters are private fields of your component class annotated with @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Parameter.html">Parameter</a>. Component parameters represent a two-way binding of a field of your component and a property or resource of its containing component or page.</p><h2 id="ComponentClasses-PersistentFields">Persistent Fields</h2><p>Main Article: <a  href="persistent-page-data.html">Persistent Page Data</a></p><p>Most fields in component classes are automatically cleared at the end of each request. However, fields may be annotated so that they retain their value across requests, using the @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Persist.html">Persist</a> annotation.</p
 ><h2 id="ComponentClasses-Embedded_ComponentsEmbeddedComponents"><parameter ac:name="">Embedded_Components</parameter>Embedded Components</h2><p>Components often contain other components. Components inside another component's template are called <em>embedded components</em>. The containing component's <a  href="component-templates.html">template</a> will contain special elements, in the Tapestry namespace, identifying where the the embedded components go.</p><p>You can define the type of component inside template, or you can create an instance variable for the component and use the @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Component.html">Component</a> annotation to define the component type and parameters.</p><p>Example:</p><parameter ac:name="language">java</parameter><plain-text-body>package org.example.app.pages;
+</pre>
+</div></div><h2 id="ComponentClasses-Parameters">Parameters</h2><p>Main Article: <a  href="component-parameters.html">Component Parameters</a></p><p>Component parameters are private fields of your component class annotated with @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Parameter.html">Parameter</a>. Component parameters represent a two-way binding of a field of your component and a property or resource of its containing component or page.</p><h2 id="ComponentClasses-PersistentFields">Persistent Fields</h2><p>Main Article: <a  href="persistent-page-data.html">Persistent Page Data</a></p><p>Most fields in component classes are automatically cleared at the end of each request. However, fields may be annotated so that they retain their value across requests, using the @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Persist.html">Persist</a> annotation.</p><h2 i
 d="ComponentClasses-Embedded_ComponentsEmbeddedComponents"><span class="confluence-anchor-link" id="ComponentClasses-Embedded_Components"></span>Embedded Components</h2><p>Components often contain other components. Components inside another component's template are called <em>embedded components</em>. The containing component's <a  href="component-templates.html">template</a> will contain special elements, in the Tapestry namespace, identifying where the the embedded components go.</p><p>You can define the type of component inside template, or you can create an instance variable for the component and use the @<a  class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/Component.html">Component</a> annotation to define the component type and parameters.</p><p>Example:</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;">package org.example.app.pages;
 
 import org.apache.tapestry5.annotations.Component;
 import org.apache.tapestry5.annotations.Property;
@@ -120,7 +207,8 @@ public class Countdown
     @Property
     private int countValue;
 }
-</plain-text-body><p>The above defines a component whose embedded id is "count" (this id is derived from the name of the field and an element with that id must be present in the corresponding template, otherwise an error is displayed (see below)). The type of the component is org.example.app.components.Count. The start and end parameters of the Count component are bound to literal values, and the value parameter of the Count component is bound to the countValue property of the Countdown component.</p><p>Technically, the start and end parameters should be bound to properties, just like the value parameter. However, certain literal values, such as the numeric literals in the example, are accepted by the <code>prop:</code> binding prefix even though they are not actually properties (this is largely as a convenience to the application developer). We could also use the <code>literal:</code> prefix, <code>"start=literal:5"</code>, which accomplishes largely the same thing.</p><p>You may s
 pecify additional parameters inside the component template, but parameters in the component class take precedence.</p><p><strong>TODO: May want a more complex check; what if user uses prop: in the template and there's a conflict?</strong></p><p>You may override the default component id (as derived from the field name) using the id() attribute of the Component annotation.</p><p>If you define a component in the component class, and there is no corresponding element in the template, Tapestry will log an error. In the example above that would be the case if the template for the Countdown page didn't contain an element with <code>&lt;t:count t:id="count"&gt;</code>.</p></div>
+</pre>
+</div></div><p>The above defines a component whose embedded id is "count" (this id is derived from the name of the field and an element with that id must be present in the corresponding template, otherwise an error is displayed (see below)). The type of the component is org.example.app.components.Count. The start and end parameters of the Count component are bound to literal values, and the value parameter of the Count component is bound to the countValue property of the Countdown component.</p><p>Technically, the start and end parameters should be bound to properties, just like the value parameter. However, certain literal values, such as the numeric literals in the example, are accepted by the <code>prop:</code> binding prefix even though they are not actually properties (this is largely as a convenience to the application developer). We could also use the <code>literal:</code> prefix, <code>"start=literal:5"</code>, which accomplishes largely the same thing.</p><p>You may specify
  additional parameters inside the component template, but parameters in the component class take precedence.</p><p><strong>TODO: May want a more complex check; what if user uses prop: in the template and there's a conflict?</strong></p><p>You may override the default component id (as derived from the field name) using the id() attribute of the Component annotation.</p><p>If you define a component in the component class, and there is no corresponding element in the template, Tapestry will log an error. In the example above that would be the case if the template for the Countdown page didn't contain an element with <code>&lt;t:count t:id="count"&gt;</code>.</p></div>
       </div>
 
       <div class="clearer"></div>

Modified: websites/production/tapestry/content/component-events-faq.html
==============================================================================
--- websites/production/tapestry/content/component-events-faq.html (original)
+++ websites/production/tapestry/content/component-events-faq.html Sat Sep 16 01:54:19 2017
@@ -27,6 +27,16 @@
       </title>
   <link type="text/css" rel="stylesheet" href="/resources/space.css" />
 
+          <link href='/resources/highlighter/styles/shCoreCXF.css' rel='stylesheet' type='text/css' />
+    <link href='/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' />
+    <script src='/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
+          <script src='/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
+          <script src='/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
+          <script src='/resources/highlighter/scripts/shBrushPlain.js' type='text/javascript'></script>
+        <script>
+      SyntaxHighlighter.defaults['toolbar'] = false;
+      SyntaxHighlighter.all();
+    </script>
   
   <link href="/styles/style.css" rel="stylesheet" type="text/css"/>
 
@@ -67,7 +77,7 @@
       </div>
 
       <div id="content">
-                <div id="ConfluenceContent"><plain-text-body>{scrollbar}</plain-text-body> 
+                <div id="ConfluenceContent"> 
 
 <h2 id="ComponentEventsFAQ-ComponentEvents">Component Events </h2>
 
@@ -98,8 +108,7 @@
 <h3 id="ComponentEventsFAQ-IspecifiedazoneinmyActionLink/EventLink,sowhydoesn'tmyeventfireviaajax(request.isXHR()isfalse)?">I specified a zone in my ActionLink/EventLink, so why doesn't my event fire via ajax (request.isXHR() is false)?</h3>
 
 <p>Check your browser's JavaScript console for errors. It's likely that a JavaScript error has prevented Tapestry from transforming your ActionLink/EventLink from a page render action to an ajax action.</p>
-
-<plain-text-body>{scrollbar}</plain-text-body></div>
+</div>
       </div>
 
       <div class="clearer"></div>



Mime
View raw message