Author: mck
Date: Tue Jan 1 23:21:49 2013
New Revision: 1427588
URL: http://svn.apache.org/viewvc?rev=1427588&view=rev
Log:
push to staging the doc improvements from Michael Isvy
http://svn.apache.org/viewvc?view=revision&revision=1427575
Modified:
tiles/site/staging/framework/tutorial/advanced/wildcard.html
Modified: tiles/site/staging/framework/tutorial/advanced/wildcard.html
URL:
http://svn.apache.org/viewvc/tiles/site/staging/framework/tutorial/advanced/wildcard.html?rev=1427588&r1=1427587&r2=1427588&view=diff
==============================================================================
--- tiles/site/staging/framework/tutorial/advanced/wildcard.html (original)
+++ tiles/site/staging/framework/tutorial/advanced/wildcard.html Tue Jan 1
23:21:49 2013
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia at Jul 11, 2012 -->
+<!-- Generated by Apache Maven Doxia at Jan 2, 2013 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -10,7 +10,7 @@
@import url("../../css/site.css");
</style>
<link rel="stylesheet" href="../../css/print.css" type="text/css"
media="print" />
- <meta name="Date-Revision-yyyymmdd" content="20120711" />
+ <meta name="Date-Revision-yyyymmdd" content="20130102" />
<meta http-equiv="Content-Language" content="en" />
</head>
@@ -30,8 +30,8 @@
<div class="xleft">
- <span id="publishDate">Last Published: 2012-07-11</span>
- | <span id="projectVersion">Version: 3.0.1</span>
+ <span id="publishDate">Last Published: 2013-01-02</span>
+ | <span id="projectVersion">Version:
3.0.2-SNAPSHOT</span>
</div>
<div class="xright"> <a
href="http://www.apache.org" class="externalLink" title="Apache">Apache</a>
|
@@ -225,23 +225,55 @@
</div>
<div id="bodyColumn">
<div id="contentBox">
- <!-- $Id: wildcard.apt 1310865 2012-04-07 21:01:22Z nlebas $ --><!--
--><!-- 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. --><!-- --><div
class="sectio
n"><h2>Wildcard support<a name="Wildcard_support"></a></h2><p>By default,
Tiles supports wildcards in definition names. Wilcards help a lot in writing
less code to declare your definitions.</p><p>There are two
styles:</p><ul><li>the wildcard-based style (available by
default):<div><pre><definition name="test.definition*.message*"
template="/layout{1}.jsp">
+ <!-- $Id: wildcard.apt 1427575 2013-01-01 22:22:03Z mck $ --><!--
--><!-- 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. --><!-- --><div
class="section">
<h2>Wildcard support<a name="Wildcard_support"></a></h2><p>By default, Tiles
supports wildcards in definition names. Wilcards help a lot in writing less
code to declare your definitions.</p><div class="section"><h3>Default
configuration<a name="Default_configuration"></a></h3><p>Note: default
configuration only works if you do not use
<tt>CompleteAutoloadTilesContainerFactory</tt>. If you are using this setting,
you can move to the next section.</p><p>Let us start with a simple example.
When not using wildcards, you might end up with such tiles
definitions:</p><div><pre><definition name="bank/user"
template="/layout.jsp">
+ <put-attribute name="header"
value="/header.jsp"/>
+ <put-attribute name="body" value="/user.jsp"/>
+</definition>
+
+<definition name="bank/account"
template="/layout.jsp">
+ <put-attribute name="header"
value="/header.jsp"/>
+ <put-attribute name="body"
value="/account.jsp"/>
+</definition>
+
+<definition name="bank/customer"
template="/layout.jsp">
+ <put-attribute name="header"
value="/header.jsp"/>
+ <put-attribute name="body"
value="/customer.jsp"/>
+</definition></pre></div><p>The above definitions are pretty verbose as
you need to create one definition per JSP that you're adding to your
application. You could use definition inheritance to reduce the number of lines
but you would still need one definition per JSP.</p><div
class="section"><h4>Single star '*'<a name="Single_star_"></a></h4><p>Let's see
how to improve that using wildcards. You would then
have:</p><div><pre><definition name="bank/*"
template="/layout.jsp">
+ <put-attribute name="header"
value="/header.jsp"/>
+ <put-attribute name="body" value="/{1}.jsp"/>
+</definition>
+</pre></div><p>Calling a view named "bank/user" matches the above
definition name. Inside the "body" attributes, {1} refers to the
star's value which is "user" in that case.</p></div><div
class="section"><h4>Multiple stars such as in '*/*'<a
name="Multiple_stars_such_as_in_"></a></h4><p>Let's now consider another case.
As you can see, the sample below uses 2 stars '*'.</p><div><pre><definition
name="bank/*/*" template="/layout.jsp">
+ <put-attribute name="header"
value="/header.jsp"/>
+ <put-attribute name="body"
value="/{1}-{2}.jsp"/>
+</definition>
+</pre></div><p>Calling a view named "/bank/customer/account" matches
the above definition name. Inside the 'body' attribute, {1} refers to the first
star and {2} refers to the second one. The "body" JSP name will be
"customer-account.jsp".</p><p>Here is another example which shows
that you can use package-style definition names:</p><div><pre><definition
name="test.definition*.message*"
template="/layout{1}.jsp">
<put-attribute name="title" value="This definition has
a message: {2}."/>
<put-attribute name="header"
value="/header.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
-</definition></pre></div></li></ul><div class="section"><h3><a
name="Using_different_pattern_matching_languages">Using different pattern
matching languages</a></h3><p>If you're using the
<tt>CompleteAutoloadTilesContainerFactory</tt>, you must use a predix to
specify the pattern matching language you're using: either WILDCARD or
REGEXP:</p><div><pre><definition
name="WILDCARD:test.definition*.message*"
template="/layout{1}.jsp">
+</definition></pre></div></div></div><div class="section"><h3>Using
prefixes<a name="Using_prefixes"></a></h3><div class="section"><h4>Enabling
CompleteAutoloadTilesContainerFactory<a
name="Enabling_CompleteAutoloadTilesContainerFactory"></a></h4><p>As a
prerequisite for using prefixes, you need to have
CompleteAutoloadTilesContainerFactory enabled.</p><p>If you haven't enabled it
yet, here is a quick checklist for you to use.</p><p>The library tiles-extras
is required. If you're using Maven, you need to add this dependency to you POM
file:</p><div><pre><dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-extras</artifactId>
+ <version>2.2.2</version>
+</dependency></pre></div><p>If you are using Spring, you should add the
'completeAutoload' attribute to your TilesConfigurer
bean.</p><div><pre><bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
+ <property name="completeAutoload"
value="true"/>
+</bean></pre></div></div><div class="section"><h4>Using prefixes for
wildcards and Regular Expressions<a
name="Using_prefixes_for_wildcards_and_Regular_Expressions"></a></h4><p>When
using completeAutoload, you can use wildcard expressions and/or regexp. Each of
them should be enabled using the dedicated prefix as follows.</p><div
class="section"><h5>WILDCARD<a
name="WILDCARD"></a></h5><div><pre><definition
name="WILDCARD:test.definition*.message*"
template="/layout{1}.jsp">
<put-attribute name="title" value="This definition has
a message: {2}."/>
<put-attribute name="header"
value="/header.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
-</definition></pre></div><p>And, if you want to use Regular
Expressions:</p><div><pre><definition
name="REGEXP:test\.definition(.*)\.message(.*)"
template="/layout{1}.jsp">
+</definition>
+
+<definition name="WILDCARD:bank/*"
template="/layout.jsp">
+ <put-attribute name="header"
value="/header.jsp"/>
+ <put-attribute name="body" value="/{1}.jsp"/>
+</definition></pre></div><p>And, if you want to use Regular
Expressions:</p></div><div class="section"><h5>REGEXP<a
name="REGEXP"></a></h5><div><pre><definition
name="REGEXP:test\.definition(.*)\.message(.*)"
template="/layout{1}.jsp">
<put-attribute name="title" value="This definition has
a message: {2}."/>
<put-attribute name="header"
value="/header.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
-</definition></pre></div><p>In both cases, if you insert a definition
that matches the definition, for
example:</p><div><pre><tiles:insertDefinition
name="test.definitionOne.messageThisIsAMessage"
/></pre></div><p>The definition is automatically mapped, replacing
placeholders, marked by curly brackets, with the value of matched definitions.
In this case:</p><div><pre><definition
name="test.definitionOne.messageThisIsAMessage"
template="/layoutOne.jsp">
+</definition></pre></div></div><div
class="section"><h5>tiles:insertDefinition<a
name="tiles:insertDefinition"></a></h5><p>In both cases, if you insert a
definition that matches the definition, for
example:</p><div><pre><tiles:insertDefinition
name="test.definitionOne.messageThisIsAMessage"
/></pre></div><p>The definition is automatically mapped, replacing
placeholders, marked by curly brackets, with the value of matched definitions.
In this case:</p><div><pre><definition
name="test.definitionOne.messageThisIsAMessage"
template="/layoutOne.jsp">
<put-attribute name="title" value="This definition has
a message: ThisIsAMessage."/>
<put-attribute name="header"
value="/header.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
-</definition></pre></div></div></div>
+</definition></pre></div></div></div></div></div>
</div>
</div>
<div class="clear">
@@ -249,7 +281,7 @@
</div>
<div id="footer">
<div class="xright">
- Copyright © 2001-2012
+ Copyright © 2001-2013
<a href="http://www.apache.org">Apache Software
Foundation</a>.
All Rights Reserved.