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 2015/04/04 04:19:35 UTC

svn commit: r946270 - in /websites/production/tapestry/content: cache/main.pageCache configuration.html using-beaneditform-to-create-user-forms.html

Author: buildbot
Date: Sat Apr  4 02:19:35 2015
New Revision: 946270

Log:
Production update by buildbot for tapestry

Modified:
    websites/production/tapestry/content/cache/main.pageCache
    websites/production/tapestry/content/configuration.html
    websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html

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

Modified: websites/production/tapestry/content/configuration.html
==============================================================================
--- websites/production/tapestry/content/configuration.html (original)
+++ websites/production/tapestry/content/configuration.html Sat Apr  4 02:19:35 2015
@@ -125,11 +125,11 @@
                             </div>
         </li></ul>
 </div><h1 id="Configuration-ConfiguringTapestry">Configuring Tapestry</h1><p>This page discusses all the ways in which Tapestry can be configured. Tapestry applications are configured almost entirely using Java, with very little XML at all.</p><p><strong>Contents</strong></p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1428085157009 {padding: 0px;}
-div.rbtoc1428085157009 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1428085157009 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1428113956931 {padding: 0px;}
+div.rbtoc1428113956931 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1428113956931 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1428085157009">
+/*]]>*/</style></p><div class="toc-macro rbtoc1428113956931">
 <ul class="toc-indentation"><li><a shape="rect" href="#Configuration-XMLconfiguration(web.xml)">XML configuration (web.xml)</a></li><li><a shape="rect" href="#Configuration-YourApplication'sModuleClass">Your Application's Module Class</a></li><li><a shape="rect" href="#Configuration-ConfigurationSymbolNames">Configuration Symbol Names</a></li><li><a shape="rect" href="#Configuration-SettingComponentParameterDefaults">Setting Component Parameter Defaults</a></li><li><a shape="rect" href="#Configuration-ConfiguringIgnoredPaths">Configuring Ignored Paths</a></li><li><a shape="rect" href="#Configuration-ConfiguringContentTypeMapping">Configuring Content Type Mapping</a></li><li><a shape="rect" href="#Configuration-SettingExecutionModes">Setting Execution Modes</a></li></ul>
 </div><h2 id="Configuration-XMLconfiguration(web.xml)">XML configuration (web.xml)</h2><p>Tapestry runs on top of the standard Java Servlet API. To the servlet container, such as Tomcat, Tapestry appears as a <em>servlet filter</em>. This gives Tapestry great flexibility in matching URLs without requiring lots of XML configuration.</p><p>Although most configuration is done with Java, a small but necessary amount of configuration occurs inside the servlet deployment descriptor, WEB-INF/web.xml. Most of the configuration is boilerplate, nearly the same for all applications.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>web.xml (partial)</b></div><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;!DOCTYPE web-app
@@ -600,7 +600,7 @@ configuration.add(ComponentParameterCons
     &lt;/configuration&gt;
 &lt;/plugin&gt;
 ]]></script>
-</div></div><p>3. Add the parameter to the Surfire plugin for your test:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent panelContent pdl">
+</div></div><p>3. Add the parameter to the Surefire plugin for your test:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;plugin&gt;
     &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
     &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
@@ -612,7 +612,7 @@ configuration.add(ComponentParameterCons
     &lt;/configuration&gt;
 &lt;/plugin&gt;
 ]]></script>
-</div></div><p>For each mode declared in your JVM System Property, TapestryFilter checks for a parameter in your web.xml, named tapestry.TheModeName-modules, with TheModeName being the name of the desired mode. Its value will be a comma-separated list of modules.</p><p>If the tapestry.execution-mode is not declared, Tapestry will automatically look for the tapestry.production-modules parameter, because &#8220;production&#8221; is the default tapestry.execution-mode value.</p><p>The example below defines two differents execution modes in your web.xml file: production (the default value) and DevelopmentMode. For each mode, we list the modules we want to load. If we use JVM System property declared in the example above, the UatModeModule&#160;module will be loaded.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent panelContent pdl">
+</div></div><p>For each mode declared in your JVM System Property, TapestryFilter checks for a parameter in your web.xml, named tapestry.TheModeName-modules, with TheModeName being the name of the desired mode. Its value will be a comma-separated list of modules.</p><p>If the tapestry.execution-mode is not declared, Tapestry will automatically look for the tapestry.production-modules parameter, because &#8220;production&#8221; is the default tapestry.execution-mode value.</p><p>The example below defines two different execution modes in your web.xml file: production (the default value) and uat (for "user acceptance testing"). For each mode, we list the modules we want to load. If we use JVM System property declared in the example above, the UatModeModule&#160;module will be loaded.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;context-param&gt;
     &lt;param-name&gt;tapestry.production-modules&lt;/param-name&gt;
     &lt;param-value&gt;com.example.myapp.services.ProductionModeModule&lt;/param-value&gt;

Modified: websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html
==============================================================================
--- websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html (original)
+++ websites/production/tapestry/content/using-beaneditform-to-create-user-forms.html Sat Apr  4 02:19:35 2015
@@ -141,7 +141,7 @@ PropertyDisplayBlocks: org.apache.tapest
           T5Dashboard: org.apache.tapestry5.corelib.pages.T5Dashboard
        address/Create: com.example.tutorial.pages.address.CreateAddress
 address/CreateAddress: com.example.tutorial.pages.address.CreateAddress]]></script>
-</div></div><p><span style="line-height: 1.4285715;">Tapestry users the shortest alias when constructing URLs.</span></p><pre><span style="line-height: 1.4285715;">Eventually, your application will probably have more entities: perhaps you'll have a "user/Create" page and a "payment/Create" page and an "account/Create" page. You </span><em style="line-height: 1.4285715;">could</em><span style="line-height: 1.4285715;"> have a bunch of different classes all named Create spread across a number of different packages. That's legal Java, but it isn't ideal. You may find yourself accidentally editing the Java code for creating an Account when your really want to be editing the code for creating a Payment.</span></pre><p>Tapestry is encouraging you to use a more descriptive name: Create<em>Address</em>, not just Create, but it isn't making you pay the cost (in terms of longer, uglier URLs). The URL to access the page will still be <a shape="rect" class="external-link" href="http://localhost
 :8080/tutorial1/address/create" >http://localhost:8080/tutorial1/address/create</a>.</p><p>And remember, regardless of the name that Tapestry assigns to your page, the template file is named like the Java class itself: CreateAddress.tml.</p>    <div class="aui-message hint shadowed information-macro">
+</div></div><p><span style="line-height: 1.4285715;">Tapestry users the shortest alias when constructing URLs.</span></p><p><span style="line-height: 1.4285715;">Eventually, your application will probably have more entities: perhaps you'll have a "user/Create" page and a "payment/Create" page and an "account/Create" page. You </span><em style="line-height: 1.4285715;">could</em><span style="line-height: 1.4285715;"> have a bunch of different classes all named Create spread across a number of different packages. That's legal Java, but it isn't ideal. You may find yourself accidentally editing the Java code for creating an Account when you really want to be editing the code for creating a Payment.</span></p><p>Tapestry is encouraging you to use a more descriptive name: Create<em>Address</em>, not just Create, but it isn't making you pay the cost (in terms of longer, uglier URLs). The URL to access the page will still be <a shape="rect" class="external-link" href="http://localhost:8080
 /tutorial1/address/create" >http://localhost:8080/tutorial1/address/create</a>.</p><p>And remember, regardless of the name that Tapestry assigns to your page, the template file is named like the Java class itself: CreateAddress.tml.</p>    <div class="aui-message hint shadowed information-macro">
                             <span class="aui-icon icon-hint">Icon</span>
                 <div class="message-content">
                             <p>Index pages work in folders as well. A class named com.example.tutorial.pages.address.AddressIndex would be given the name "address/Index". However, Tapestry has special rules for pages named "Index" and the rendered URL would be <a shape="rect" class="external-link" href="http://localhost:8080/tutorial1/address/" >http://localhost:8080/tutorial1/address/</a>. In other words, you can place Index pages in any folder and Tapestry will build a short URL for that page ... and you <em>don't</em> have to keep naming the classes Index (it's confusing to have many classes with the same name, even across multiple packages); instead, you can name each index page after the package that contains it. Tapestry users a smart <em>convention</em> to keep it all straight and generate short, to the point URLs.</p>
@@ -154,7 +154,7 @@ address/CreateAddress: com.example.tutor
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[    @Property
     private Address address;
 ]]></script>
-</div></div><p>When you refresh the page, you may see the warning like the following at the top of the page:</p><p><img class="confluence-embedded-image" src="using-beaneditform-to-create-user-forms.data/hmac-warning.png" data-image-src="/confluence/download/attachments/23340431/hmac-warning.png?version=2&amp;modificationDate=1416883285000&amp;api=v2"></p><p>If you see that, it means you need to invent an HMAC passphrase for your app. Just edit your AppModule.java class (in your services package), adding a couple of lines to the contributeApplicationDefaults method like the following:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>When you refresh the page, you may see a warning like the following at the top of the page:</p><p><img class="confluence-embedded-image" src="using-beaneditform-to-create-user-forms.data/hmac-warning.png" data-image-src="/confluence/download/attachments/23340431/hmac-warning.png?version=2&amp;modificationDate=1416883285000&amp;api=v2"></p><p>If you see that, it means you need to invent an HMAC passphrase for your app. Just edit your AppModule.java class (in your services package), adding a couple of lines to the contributeApplicationDefaults method like the following:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[        // Set the HMAC pass phrase to secure object data serialized to client
         configuration.add(SymbolConstants.HMAC_PASSPHRASE, &quot;&quot;);]]></script>
 </div></div><p>but, instead of an empty string, insert a long, <strong>random string of characters</strong> (like a very long and complex password, at least 30 characters) that you keep private.</p><p>After you do that, stop the app and restart it, and click on the Create new address link again, and you'll see something like this:</p><p><img class="confluence-embedded-image" src="using-beaneditform-to-create-user-forms.data/create-address-initial.png" data-image-src="/confluence/download/attachments/23340431/create-address-initial.png?version=2&amp;modificationDate=1416884366000&amp;api=v2"></p><p>Tapestry has done quite a bit of work here. It has created a form that includes a field for each property. Further, it has seen that the honorific property is an enumerated type, and presented that as a drop-down list.</p><p>In addition, Tapestry has converted the property names ("city", "email", "firstName") to user presentable labels ("City", "Email", "First Name"). In fact, these are &l
 t;label&gt; elements, so clicking a label with the mouse will move the input cursor into the corresponding field.</p><p>This is an awesome start; it's a presentable interface, quite nice in fact for a few minute's work. But it's far from perfect; let's get started with some customizations.</p><h1 id="UsingBeanEditFormToCreateUserForms-ChangingFieldOrder">Changing Field Order</h1><p>The BeanEditForm must guess at the right order to present the fields; for public fields, they end up in alphabetical order. For standard JavaBeans properties, the BeanEditForm default is in the order in which the getter methods are defined in the class (it uses line number information, if available).</p><p>A better order for these fields is the order in which they are defined in the Address class:</p><ul><li>honorific</li><li>firstName</li><li>lastName</li><li>street1</li><li>street2</li><li>city</li><li>state</li><li>zip</li><li>email</li><li>phone</li></ul><p>We can accomplish this by using the <code>re
 order</code> parameter of the BeanEditForm component, which is a comma separated list of property (or public field) names:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>CreateAddress.tml (partial)</b></div><div class="codeContent panelContent pdl">