You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/02/08 23:20:28 UTC

svn commit: r620012 - in /tapestry/tapestry5/trunk: ./ tapestry-core/src/main/java/org/apache/tapestry/services/ tapestry-core/src/site/ tapestry-core/src/site/apt/guide/ tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/

Author: hlship
Date: Fri Feb  8 14:20:26 2008
New Revision: 620012

URL: http://svn.apache.org/viewvc?rev=620012&view=rev
Log:
TAPESTRY-2142: Document the Layout component pattern

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/layout.apt
Removed:
    tapestry/tapestry5/trunk/tapestry5.ipr
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/assets.apt
    tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/coercion.apt
    tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=620012&r1=620011&r2=620012&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Fri Feb  8 14:20:26 2008
@@ -548,10 +548,6 @@
      */
     public static void contributeTranslatorSource(MappedConfiguration<String, Translator> configuration)
     {
-        // Fortunately, the translators are tiny, so we don't have to worry about the slight
-        // duplication between this and TranslatorDefaultSource, though it is a pain to keep the two
-        // organized (perhaps they should be joined together into a single service, where we
-        // identify a name and a match type).
 
         configuration.add("string", new StringTranslator());
         configuration.add("byte", new ByteTranslator());
@@ -671,7 +667,7 @@
     {
         // make the name match the annotation class name.
 
-        String name = TapestryInternalUtils.lastTerm(annotationClass.getName());
+        String name = annotationClass.getSimpleName();
 
         configuration.add(name, new ComponentLifecycleMethodWorker(signature, annotationClass, reverse));
     }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/assets.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/assets.apt?rev=620012&r1=620011&r2=620012&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/assets.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/assets.apt Fri Feb  8 14:20:26 2008
@@ -75,7 +75,7 @@
   If you wish to create new domains for assets, for example to allow assets to be stored on the file system or in a database,
   you may define a new
   {{{../../apidocs/org/apache/tapestry/services/AssetFactory.html}AssetFactory}}
-  and contribute it to the tapestry.AssetSource service configuration.  
+  and contribute it to the AssetSource service configuration.  
   
 Simplified Paths
 
@@ -89,7 +89,7 @@
     public static void contributeClasspathAssetAliasManager(
             MappedConfiguration<String, String> configuration)
     {
-        configuration.add("tapestry/", "org/apache/tapestry/");
+        configuration.add("tapestry", "org/apache/tapestry");
     }
 +---+
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/coercion.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/coercion.apt?rev=620012&r1=620011&r2=620012&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/coercion.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/coercion.apt Fri Feb  8 14:20:26 2008
@@ -42,7 +42,7 @@
 TypeCoercer Service
 
   The TypeCoercer service is responsible for this type coercion. This service is part of the tapestry-ioc module, and 
-  is {{{http://tapestry.apache.org/tapestry5/tapestry-ioc/coerce.html}documented there}}.  The service
+  is {{{../../tapestry-ioc/coerce.html}documented there}}.  The service
   is quite extensible, allowing for new types and coercions to be added easily.  The TapestryModule contributes a few additional
   coercions into the TypeCoercer service.
   

Added: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/layout.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/layout.apt?rev=620012&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/layout.apt (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/layout.apt Fri Feb  8 14:20:26 2008
@@ -0,0 +1,106 @@
+ ----
+ Layout Component
+ ----
+
+Layout Component
+
+  You may see frequent reference to a Layout Component, but you won't find it
+  in the {{{../ref/index.html}component reference}}.  Layout isn't a component, it's
+  a component <pattern>.
+
+  A Layout component exists to provide common content across all pages in your application.
+  In traditional servlet development, you may be familiar with
+  the use of a JSP include to include a banner across the top of your page and a copyright
+  message across the bottom.
+
+  Tapestry doesn't have a mechanism for such includes, nor does it have the need.
+
+  Instead, you can create a component that acts like a template for your pages.
+
+* Layout.tml
+
+----
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    <head>
+        <title>My Nifty Web Application</title>
+    </head>
+    <body>
+        <div class="nav-top">
+            Nifty Web Application
+        </div>
+    
+        <t:body/>
+
+        <div class="nav-bottom">
+            (C) 2008 NiftyWebCo, Inc.
+        </div>
+    </body>
+</html>
+----
+
+  Layout is a standard component, with a standard component template.  Like all component
+  templates, it will be stored on the classpath (i.e., under src/main/resources).
+
+  The magic is in the \<t:body/\> element in the center; this will be replaced
+  by the <page's content>, whatever that is.
+
+  The two \<div\> elements above and below the \<t:body\> are, in this example, placeholders for
+  the typical content you'll see in a web application: banners (and banner ads!),
+  menus, login forms and so forth.
+
+  Often these get very complex ... in fact, in most applications, the Layout component grows
+  to be more complex than almost any page in the application.
+
+  Remember that if you include a link to a resource such as an image or a stylesheet, you
+  must use an absolute URL. The same component will be used for pages in many different folders,
+  or with many different activation contexts, meaning that relative URLs are not only
+  different for different pages, but may shift unexpectedly.
+
+* Layout.java
+
+----
+@IncludeStylesheet("context:css/site.css")
+public class Layout
+{
+}
+----
+
+  Components must always have a Java class. In this trivial example, the Layout component
+  does not have much logic.  We can save ourselves some typing using the
+  {{{../../apidocs/org/apache/tapestry/annotations/IncludeStylesheet.html}@IncludeStylesheet}}
+  annotation (as opposed to directly adding the
+  \<link\> element to the template.
+
+
+* Start.tml
+
+----
+<html t:type="layout" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+   <h1>Welcome to the Nifty Web Application!</h1>
+
+   <p>
+        Would you like to <t:pagelink page="login">Log In</t:pagelink>?
+   </p>
+</html>
+----
+
+  This is an example of using the Layout component.  To keep our Start.tml template
+  relatively previewable, we are using an \<html\> element and the t:type
+  attribute to specify that it is a component.
+
+  The \<html\> tag will be removed, and replaced with the content from
+  the Layout.tml template (which convieniently starts with an \<html\> element).
+  The \<t:body\> in Layout.tml will be replaced
+  with the page specific content here: the \<h1\> and \<p\> tags.
+
+  Any page in the application that follows this pattern, using the Layout component,
+  will have the same look and feel.
+
+  You may find that your application has more than one look and feel: perhaps
+  user registration pages have one look, while administrative pages have another.
+  This can be accomplished by having multiple Layout components and using different
+  layout types for different pages.
+
+
+

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml?rev=620012&r1=620011&r2=620012&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/site.xml Fri Feb  8 14:20:26 2008
@@ -62,6 +62,7 @@
             <item name="Input Validation" href="guide/validation.html"/>
             <item name="BeanEditForm Guide" href="guide/beaneditform.html"/>
             <item name="Component Events" href="guide/event.html"/>
+            <item name="Layout Component" href="guide/layout.html"/>
             <item name="CSS" href="guide/css.html"/>
             <item name="Ajax" href="guide/ajax.html"/>
             <item name="Page Lifecycle" href="guide/lifecycle.html"/>

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java?rev=620012&r1=620011&r2=620012&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java Fri Feb  8 14:20:26 2008
@@ -18,9 +18,10 @@
 
 /**
  * An immutable object that represents a mapping from one type to another. This is also the
- * contribution type when buildign the TypeCoercer service. Wraps a {@link Coercion} object that
+ * contribution type when building the {@link org.apache.tapestry.ioc.services.TypeCoercer} service.
+ * Wraps a {@link org.apache.tapestry.ioc.services.Coercion} object that
  * performs the work with additional properties that describe the input and output types of the
- * coercion, needed when searching for an appropriate coercion (or combination of coercions).
+ * coercion, needed when searching for an appropriate coercion (or sequence of coercions).
  *
  * @param <S>
  * source (input) type