You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by dd...@apache.org on 2007/01/16 17:40:24 UTC

svn commit: r496750 - /tiles/trunk/src/site/apt/quickstart/abstracting-tiles.apt

Author: ddewolf
Date: Tue Jan 16 08:40:23 2007
New Revision: 496750

URL: http://svn.apache.org/viewvc?view=rev&rev=496750
Log:
More quickstart material

Added:
    tiles/trunk/src/site/apt/quickstart/abstracting-tiles.apt

Added: tiles/trunk/src/site/apt/quickstart/abstracting-tiles.apt
URL: http://svn.apache.org/viewvc/tiles/trunk/src/site/apt/quickstart/abstracting-tiles.apt?view=auto&rev=496750
==============================================================================
--- tiles/trunk/src/site/apt/quickstart/abstracting-tiles.apt (added)
+++ tiles/trunk/src/site/apt/quickstart/abstracting-tiles.apt Tue Jan 16 08:40:23 2007
@@ -0,0 +1,123 @@
+~~ $Id$
+~~
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied.  See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+~~
+         -----------
+         Tiles Quickstart : Step 1, Abstracting Tiles
+         -----------
+
+Abstracting Tiles
+
+* Identifying Tiles
+
+ In the {{{index.html}introduction}}, we introduced the
+ concept of tiles and took a look at a basic html page
+ that we want to generate in our web application.  In
+ this step, we will abstract tiles from that page.
+
+
+ A Tile is a reusable markup fragment. The first step of using
+ tiles is extracting the fragments which are common to the
+ application out of the markup.  This allows these components
+ to be reused.
+
+ In our page, there are two common elements, the header and
+ the fotter.  Let's abstract those out into tiles.  The
+ following markup represents the necessary changes to our
+ initial markup.
+
+------------------------------------------------------------
+<div id="header">
+  Welcome to Tiles 101
+</div>
+------------------------------------------------------------
+[Header, /fragments/header.jsp]
+
+------------------------------------------------------------
+<div id=footer">
+  &#169; 2007, Apache Software Foundation
+</div>
+------------------------------------------------------------
+[Footer, /fragments/footer.jsp]
+
+
+------------------------------------------------------------
+<html>
+  <head><title>Tiles Quickstart</title><head>
+  <body>
+    <tiles:insertTemplate path="/fragments/header.jsp"/>
+
+    <div id="body">
+      Tiles 101 body content.
+    </div>
+
+    <tiles:insertTemplate path="/fragments/footer.jsp"/>
+  </body>
+</html>
+------------------------------------------------------------
+
+* Tiles and Dynamic Content
+
+ Upon abstracting this tile, we notice that the generic header,
+ which is supposedly going to allow us to minimize duplication,
+ is hard coded to welcome us to Tiles 101.  Perhaps we'd like
+ to make this tile more dynamic so that we can dynamically set
+ the name of the page we're welcoming the user to.
+
+ Let's update our tile and template:
+
+------------------------------------------------------------
+<div id="header">
+  Welcome to <tiles:getAsString name="welcome"/>
+</div>
+------------------------------------------------------------
+[Header, /fragments/header.jsp]
+
+------------------------------------------------------------
+<html>
+  <head><title>Tiles Quickstart</title><head>
+  <body>
+    <tiles:insertTemplate path="/fragments/header.jsp">
+      <tiles:putAttribute name="welcome" value="Tiles 101"/>
+    </tiles:insertTemplate>
+
+    <div id="body">
+      Tiles 101 body content.
+    </div>
+
+    <tiles:insertTemplate path="/fragments/footer.jsp"/>
+  </body>
+</html>
+------------------------------------------------------------
+[Template, index.jsp]
+
+
+
+
+   * Previous Quickstart Pages
+
+     ** {{{index.html}Introduction }}
+
+   * Next Quickstart Pages
+
+     ** {{{reusing-tiles.html}Reusing Tiles}}
+
+     ** {{{implementing-templates.html}Implementing Templates}}
+
+     ** {{{removing-configuration.html}Removing Configuration}}
+