tiles-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r533133 - in /tiles/site/src/site: apt/tutorial/advanced/index.apt apt/tutorial/advanced/preparer.apt apt/tutorial/advanced/runtime.apt apt/tutorial/advanced/utils.apt apt/tutorial/basic/pages.apt apt/tutorial/index.apt site.xml
Date Fri, 27 Apr 2007 15:09:57 GMT
Author: apetrelli
Date: Fri Apr 27 08:09:56 2007
New Revision: 533133

URL: http://svn.apache.org/viewvc?view=rev&rev=533133
Log:
TILESSHARED-10
Added more tutorial pages (2).

Added:
    tiles/site/src/site/apt/tutorial/advanced/utils.apt   (with props)
Modified:
    tiles/site/src/site/apt/tutorial/advanced/index.apt
    tiles/site/src/site/apt/tutorial/advanced/preparer.apt
    tiles/site/src/site/apt/tutorial/advanced/runtime.apt
    tiles/site/src/site/apt/tutorial/basic/pages.apt
    tiles/site/src/site/apt/tutorial/index.apt
    tiles/site/src/site/site.xml

Modified: tiles/site/src/site/apt/tutorial/advanced/index.apt
URL: http://svn.apache.org/viewvc/tiles/site/src/site/apt/tutorial/advanced/index.apt?view=diff&rev=533133&r1=533132&r2=533133
==============================================================================
--- tiles/site/src/site/apt/tutorial/advanced/index.apt (original)
+++ tiles/site/src/site/apt/tutorial/advanced/index.apt Fri Apr 27 08:09:56 2007
@@ -30,13 +30,15 @@
   [[1]] {{{nesting-extending.html}Nesting and Extending Definitions}}
 
   [[2]] {{{list-attributes.html}List Attributes}}
+        
+  [[3]] {{{runtime.html}Runtime Composition}}
 
-  [[3]] {{{preparer.html}View Preparers}}
+  [[4]] {{{preparer.html}View Preparers}}
   
-  [[4]] {{{l10n.html}Tiles Localization}}
-        
-  [[5]] {{{runtime.html}Creating Definitions at Runtime}}
+  [[5]] {{{utils.html}Rendering Utilities}}
+  
+  [[6]] {{{l10n.html}Tiles Localization}}
   
-  [[6]] {{{beans.html}Using Beans as attributes}}
+  [[7]] {{{beans.html}Using Beans as attributes}}
   
-  [[7]] {{{menu.html}Menu-ing support}}
+  [[8]] {{{menu.html}Menu-ing support}}

Modified: tiles/site/src/site/apt/tutorial/advanced/preparer.apt
URL: http://svn.apache.org/viewvc/tiles/site/src/site/apt/tutorial/advanced/preparer.apt?view=diff&rev=533133&r1=533132&r2=533133
==============================================================================
--- tiles/site/src/site/apt/tutorial/advanced/preparer.apt (original)
+++ tiles/site/src/site/apt/tutorial/advanced/preparer.apt Fri Apr 27 08:09:56 2007
@@ -21,6 +21,60 @@
          Tiles View Preparers
          -----------
 
-Introduction
+View Preparers
 
-  This is the introduction
+  Sometimes a definition, before it is rendered, needs to be "prepared". For
+  example when showing a menu, the menu structure must be created and stored
+  in the request scope.
+  
+  For this reason, a <<View Preparer>> can be used: it is called <<before>>
the
+  definition is rendered, so all the things needed to render correctly the
+  definition can be prepared.
+
+* Creating a view preparer
+
+  A View Preparer is simply a class that implement the <<<ViewPreparer>>>
+  interface. The <<<execute>>> method allows to execute code <<before>>
a
+  definition is rendered. You can extend the <<<ViewPreparerSupport>>>
class to
+  avoid compiling problems in the case the <<<ViewPreparer>>> interface
changes.
+
+----------------------------------------------
+package my.package;
+
+import org.apache.tiles.preparer.PreparerException;
+import org.apache.tiles.preparer.ViewPreparer;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.AttributeContext;
+import org.apache.tiles.Attribute;
+
+public class TestViewPreparer implements ViewPreparer {
+
+    public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext)
+    throws PreparerException {
+        attributeContext.putAttribute(
+            "body",
+            new Attribute("This is the value added by the ViewPreparer"));
+    }
+}
+----------------------------------------------
+
+* Associating a preparer
+
+  To associate a preparer to a definition, put its complete path name to the
+  <<<preparer>>> attribute of the <<<\<definition\>>>>
element:
+
+----------------------------------------------
+<definition name="preparer.definition" preparer="org.apache.tiles.test.preparer.TestViewPreparer">
+  <put-attribute name="foo" value="/bar/foo.jsp" />
+</definition>  
+----------------------------------------------
+
+* Customizing View Preparer association
+
+  Currently the preparer is associated to a definition using its class name.
+  There will be only <<one>> instance per unique class name. If you want to
+  customize this behaviour, you have to create your own implementation of the
+  <<<PreparerFactory>>> interface.
+  
+  For example, the {{{../integration/frameworks.html}Struts 1 - Tiles 2 integration}}
+  defines a <<<PreparerFactory>>> that can use a URL as a preparer.

Modified: tiles/site/src/site/apt/tutorial/advanced/runtime.apt
URL: http://svn.apache.org/viewvc/tiles/site/src/site/apt/tutorial/advanced/runtime.apt?view=diff&rev=533133&r1=533132&r2=533133
==============================================================================
--- tiles/site/src/site/apt/tutorial/advanced/runtime.apt (original)
+++ tiles/site/src/site/apt/tutorial/advanced/runtime.apt Fri Apr 27 08:09:56 2007
@@ -18,9 +18,137 @@
 ~~ under the License.
 ~~
          -----------
-         Creating Tiles Definitions at Runtime
+         Tiles Runtime Composition
          -----------
 
-Introduction
+Tiles Runtime Composition
 
-  This is the introduction
+  Tiles allows to create statically-determined page structures, like we've seen
+  in {{{../basic/pages.html}Creating Pages}}. But Tiles allows to fill
+  templates, modify definitions and create new definitions during the execution.
+
+Runtime Composition in JSP pages
+
+  Making runtime changes in JSP pages is pretty simple. You can use special JSP
+  tags that allow to create page structures on-the-fly.
+
+* Inserting templates
+
+  You can insert a template directly inside a JSP page, filling its attributes
+  at runtime. To do it, you can use the <<<\<tiles:insertTemplate\>>>>
tag. The
+  attributes can be put using <<<\<tiles:putAttribute\>>>> and related
tags.
+
+-----------------------------------
+<tiles:insertTemplate template="/layouts/classic.jsp">
+  <tiles:putAttribute name="title" value="Tiles tutorial homepage" />
+  <tiles:putAttribute name="header" value="/tiles/banner.jsp" />
+  <tiles:putAttribute name="menu" value="/tiles/common_menu.jsp" />
+  <tiles:putAttribute name="body">
+    <tiles:insertTemplate template="/layouts/variable_rows.jsp">
+      <tiles:putListAttribute name="items">
+        <tiles:addAttribute value="/tiles/banner.jsp" />
+        <tiles:addAttribute value="/tiles/common_menu.jsp" />
+        <tiles:addAttribute value="/tiles/credits.jsp" />
+      </tiles:putListAttribute>
+    </tiles:insertTemplate>
+  </tiles:putAttribute
+  <tiles:putAttribute name="footer" value="/tiles/credits.jsp" />
+</tiles:insertTemplate>
+-----------------------------------
+
+* Inserting modified definitions
+
+  Definitions can be inserted not only just as they are, but also overriding
+  their attributes at runtime:
+
+------------------------------------
+<tiles:insertDefinition name="myapp.homepage.customer">
+  <tiles:putAttribute name="menu" value="/tiles/common_menu_for_customers.jsp" />
+</tiles:insertDefinition>
+------------------------------------
+
+  Note: Currently it is not possible to override a template at runtime.
+
+* Creating Definitions
+
+  To create definitions at runtime, first of all you need to configure your
+  Tiles-based application to use a
+  {{{../../config-reference.html#org.apache.tiles.CONTAINER_FACTORY.mutable}mutable container}}.
+  
+  In your JSP page, now you can create definitions. This definition will be
+  available during the request, and then it will expire.
+
+-----------------------------------------
+<tiles:definition name="myapp.homepage.customer" extends="myapp.homepage">
+  <tiles:putAttribute name="menu" value="/tiles/common_menu_for_customers.jsp" />
+</tiles:insertDefinition>
+<tiles:insertDefinition name="myapp.homepage.customer" />
+-----------------------------------------
+
+Runtime Composition using APIs
+
+  If you want to compose pages using the Tiles APIs, for example in a servlet
+  environment, you can use the <<container>> feature of Tiles. Essentially Tiles
+  is a container that stores definitions, allow to render pages and allows to
+  modify the configuration at runtime.
+  
+* Using the Tiles container
+
+  To get the current container (in a servlet environment) you can use the
+  <<TilesAccess>> class:
+  
+-------------------------------------
+TilesContainer container = TilesAccess.getContainer(
+        request.getSession().getServletContext());
+-------------------------------------
+
+  If you want to render a template including the values of its attributes, you
+  can use an <<<AttributeContext>>>: this object stores the current values
of
+  all the configured attributes.
+
+--------------------------------------
+TilesAttributeContext attributeContext = container.getAttributeContext(request,
+        response);
+--------------------------------------
+
+  You can create (push) and destroy (pop) a temporary attribute context during
+  your execution, by using the <<startContext>> and <<endContext>>
methods of
+  the Tiles container:
+
+--------------------------------------
+TilesAttributeContext attributeContext = container.startContext(request,
+        response);
+attributeContext.setAttribute("body", "/tiles/body_customer.jsp");
+container.render("myapp.homepage", request, response);
+container.endContext(request, response);
+--------------------------------------
+
+  You can forward/include a template page: if there is an attribute context that
+  contains all of its attributes filled, it will be rendered correctly.
+
+--------------------------------------
+TilesAttributeContext attributeContext = container.startContext(request,
+        response);
+attributeContext.setAttribute("body", "/tiles/body_customer.jsp");
+// Put all the other attributes.
+RequestDispatcher rd = request.getRequestDispatcher("/layouts/my_template.jsp");
+rd.forward(request, response);
+container.endContext(request, response);
+--------------------------------------
+
+* Creating Definitions
+
+  To create definitions at runtime, first of all you need to configure your
+  Tiles-based application to use a
+  {{{../../config-reference.html#org.apache.tiles.CONTAINER_FACTORY.mutable}mutable container}}.
+
+  This is a snippet to show how to create a definition.
+
+-------------------------------------
+MutableTilesContainer container = TilesAccess.getContainer(
+        request.getSession().getServletContext());
+TileDefinition definition = new TileDefinition();
+definition.setTemplate("/layouts/my_layout.jsp");
+definition.putAttribute("body", new Attribute("/tiles/body.jsp");
+container.register(definition, request, response);
+-------------------------------------

Added: tiles/site/src/site/apt/tutorial/advanced/utils.apt
URL: http://svn.apache.org/viewvc/tiles/site/src/site/apt/tutorial/advanced/utils.apt?view=auto&rev=533133
==============================================================================
--- tiles/site/src/site/apt/tutorial/advanced/utils.apt (added)
+++ tiles/site/src/site/apt/tutorial/advanced/utils.apt Fri Apr 27 08:09:56 2007
@@ -0,0 +1,74 @@
+~~ $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.
+~~
+         -----------
+         Rendering Utilities
+         -----------
+
+Tiles Rendering Utilities
+
+  The core package of Tiles contains utilities to render Tiles definitions
+  without the need of a JSP page or a supporting framework.
+
+* <<<TilesDispatchServlet>>>
+
+  The <<<TilesDispatchServlet>>> is a servlet that intercepts the URLs
ending
+  with "<<<.tiles>>>" and render the definition whose name is the path
name
+  before the "<<<.tiles>>>" part.
+  
+  For example, if you call the <<<testdispatchservlet.tiles>>> path, the
+  rendered definition will be <<<testdispatchservlet>>>.
+
+  You can configure the <<<TilesDispatchServlet>>> this way:
+
+------------------------------------
+<servlet>
+    <servlet-name>Tiles Dispatch Servlet</servlet-name>
+    <servlet-class>org.apache.tiles.web.TilesDispatchServlet</servlet-class>
+</servlet>
+...
+<servlet-mapping>
+    <servlet-name>Tiles Dispatch Servlet</servlet-name>
+    <url-pattern>*.tiles</url-pattern>
+</servlet-mapping>
+------------------------------------
+
+* <<<TilesDecorationFilter>>>
+
+  You can use the <<<TilesDecorationFilter>>> to use Tiles as a <decorator>
+  framework. All the requests intercepted by the filter will be put inside the
+  configured attribute of the configured definition, and then that definition is
+  rendered.
+  
+  You can configure the filter this way:
+
+------------------------------------
+<filter>
+    <filter-name>Tiles Decoration Filter</filter-name>
+    <filter-class>org.apache.tiles.web.TilesDecorationFilter</filter-class>
+    <init-param>
+        <param-name>definition</param-name>
+        <param-value>test.definition</param-value>
+    </init-param>
+    <init-param>
+        <param-name>attribute-name</param-name>
+        <param-value>body</param-value>
+    </init-param>
+</filter>
+------------------------------------

Propchange: tiles/site/src/site/apt/tutorial/advanced/utils.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/site/src/site/apt/tutorial/advanced/utils.apt
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: tiles/site/src/site/apt/tutorial/basic/pages.apt
URL: http://svn.apache.org/viewvc/tiles/site/src/site/apt/tutorial/basic/pages.apt?view=diff&rev=533133&r1=533132&r2=533133
==============================================================================
--- tiles/site/src/site/apt/tutorial/basic/pages.apt (original)
+++ tiles/site/src/site/apt/tutorial/basic/pages.apt Fri Apr 27 08:09:56 2007
@@ -134,7 +134,7 @@
 container.render("myapp.homepage", request, response);
 -----------------------------------
 
-  []
+  * by using {{{../advanced/utils.html}Rendering Utilities}} provided by Tiles.
   
   * by using a supporting framework. See
   {{{../integration/index.html}Integrations}} for a list of supporting

Modified: tiles/site/src/site/apt/tutorial/index.apt
URL: http://svn.apache.org/viewvc/tiles/site/src/site/apt/tutorial/index.apt?view=diff&rev=533133&r1=533132&r2=533133
==============================================================================
--- tiles/site/src/site/apt/tutorial/index.apt (original)
+++ tiles/site/src/site/apt/tutorial/index.apt Fri Apr 27 08:09:56 2007
@@ -44,16 +44,18 @@
         [[1]] {{{advanced/nesting-extending.html}Nesting and Extending Definitions}}
 
         [[2]] {{{advanced/list-attributes.html}List Attributes}}
-
-        [[3]] {{{advanced/preparer.html}View Preparers}}
-  
-        [[4]] {{{advanced/l10n.html}Tiles Localization}}
         
-        [[5]] {{{advanced/runtime.html}Creating Definitions at Runtime}}
+        [[3]] {{{advanced/runtime.html}Runtime Composition}}
+
+        [[4]] {{{advanced/preparer.html}View Preparers}}
+
+  		[[5]] {{{utils.html}Rendering Utilities}}
+
+        [[6]] {{{advanced/l10n.html}Tiles Localization}}
   
-        [[6]] {{{advanced/beans.html}Using Beans as attributes}}
+        [[7]] {{{advanced/beans.html}Using Beans as attributes}}
   
-        [[7]] {{{advanced/menu.html}Menu-ing support}}
+        [[8]] {{{advanced/menu.html}Menu-ing support}}
   
   [[6]] {{{integration/index.html}Integration with other technologies}}
   

Modified: tiles/site/src/site/site.xml
URL: http://svn.apache.org/viewvc/tiles/site/src/site/site.xml?view=diff&rev=533133&r1=533132&r2=533133
==============================================================================
--- tiles/site/src/site/site.xml (original)
+++ tiles/site/src/site/site.xml Fri Apr 27 08:09:56 2007
@@ -93,14 +93,17 @@
                             name="List Attributes"
                             href="/tutorial/advanced/list-attributes.html"/>
                     <item   
+                            name="Runtime Composition"
+                            href="/tutorial/advanced/runtime.html"/>
+                    <item   
                             name="View Preparers"
                             href="/tutorial/advanced/preparer.html"/>
                     <item   
+                            name="Rendering Utilities"
+                            href="/tutorial/advanced/utils.html"/>
+                    <item   
                             name="Localization"
                             href="/tutorial/advanced/l10n.html"/>
-                    <item   
-                            name="Creating Definitions at Runtime"
-                            href="/tutorial/advanced/runtime.html"/>
                     <item   
                             name="Using Beans as Attributes"
                             href="/tutorial/advanced/beans.html"/>



Mime
View raw message